Code Duplication    Length = 45-45 lines in 2 locations

rna_tools/tools/rna_calc_rmsd/rna_calc_rmsd.py 1 location

@@ 173-217 (lines=45) @@
170
    if method == 'fit':
171
        return (pymol.cmd.fit('s1', 's2'), 'fit')
172
173
def calc_rmsd(a, b, target_selection, target_ignore_selection, model_selection, model_ignore_selection, way, verbose):
174
    """
175
    Calculate RMSD between two XYZ files
176
177
    by: Jimmy Charnley Kromann <[email protected]> and Lars Andersen Bratholm <[email protected]>
178
    project: https://github.com/charnley/rmsd
179
    license: https://github.com/charnley/rmsd/blob/master/LICENSE
180
181
    a is model
182
    b is target
183
184
    :params: a = filename of structure a
185
    :params: b = filename of structure b
186
187
    :return: rmsd, number of atoms
188
    """
189
    if verbose: print('in:', a)
190
191
    atomsP, P = get_coordinates(a, model_selection, model_ignore_selection, 'pdb', True, way)
192
    atomsQ, Q = get_coordinates(b, target_selection,target_ignore_selection,  'pdb', True, way)
193
194
    if verbose:
195
        print(atomsP, P)
196
        print(atomsQ, Q)
197
198
    if atomsQ != atomsP:
199
        print('Error: number of atoms is not equal target (' + b + '):' + str(atomsQ) + ' vs model (' + a + '):' + str(atomsP))
200
        return (-1,0) # skip this RNA
201
    # Calculate 'dumb' RMSD
202
    normal_rmsd = rmsd(P, Q)
203
    # Create the centroid of P and Q which is the geometric center of a
204
    # N-dimensional region and translate P and Q onto that center.
205
    # http://en.wikipedia.org/wiki/Centroid
206
    Pc = centroid(P)
207
    Qc = centroid(Q)
208
    P -= Pc
209
    Q -= Qc
210
211
    if False:
212
        V = rotate(P, Q)
213
        V += Qc
214
        write_coordinates(atomsP, V)
215
        quit()
216
217
    return round(kabsch_rmsd(P, Q),2), atomsP
218
219
def get_parser():
220
    import argparse

rna_tools/tools/rna_calc_rmsd/rna_calc_rmsd_pymol.py 1 location

@@ 150-194 (lines=45) @@
147
    if method == 'fit':
148
        return (pymol.cmd.fit('s1', 's2'), 'fit')
149
150
def calc_rmsd(a, b, target_selection, target_ignore_selection, model_selection, model_ignore_selection, way, verbose):
151
    """
152
    Calculate RMSD between two XYZ files
153
154
    by: Jimmy Charnley Kromann <[email protected]> and Lars Andersen Bratholm <[email protected]>
155
    project: https://github.com/charnley/rmsd
156
    license: https://github.com/charnley/rmsd/blob/master/LICENSE
157
158
    a is model
159
    b is target
160
161
    :params: a = filename of structure a
162
    :params: b = filename of structure b
163
164
    :return: rmsd, number of atoms
165
    """
166
    if verbose: print('in:', a)
167
168
    atomsP, P, atoms = get_coordinates(a, model_selection, model_ignore_selection, 'pdb', True, way)
169
    atomsQ, Q, atoms = get_coordinates(b, target_selection,target_ignore_selection,  'pdb', True, way)
170
171
    if verbose:
172
        print(atomsP, P)
173
        print(atomsQ, Q)
174
175
    if atomsQ != atomsP:
176
        print('Error: number of atoms is not equal target (' + b + '):' + str(atomsQ) + ' vs model (' + a + '):' + str(atomsP))
177
        return (-1,0) # skip this RNA
178
    # Calculate 'dumb' RMSD
179
    normal_rmsd = rmsd(P, Q, atoms)
180
    # Create the centroid of P and Q which is the geometric center of a
181
    # N-dimensional region and translate P and Q onto that center.
182
    # http://en.wikipedia.org/wiki/Centroid
183
    Pc = centroid(P)
184
    Qc = centroid(Q)
185
    P -= Pc
186
    Q -= Qc
187
188
    if False:
189
        V = rotate(P, Q)
190
        V += Qc
191
        write_coordinates(atomsP, V)
192
        quit()
193
194
    return round(kabsch_rmsd(P, Q, atoms),2), atomsP
195
196
def get_parser():
197
    import argparse