Code Duplication    Length = 29-30 lines in 2 locations

rna_tools/rna_tools_lib.py 2 locations

@@ 1828-1857 (lines=30) @@
1825
                #
1826
                # fix missing G (the whole base at the moment)
1827
                #
1828
                if str(r.get_resname()).strip() == "G" and fix_missing_atoms:
1829
                    for a in r:
1830
                        if a.id == "N1":
1831
                            break
1832
                    else:
1833
                        G_struc = PDB.PDBParser().get_structure('', path + '/data/G.pdb')
1834
                        G = [G_atom for G_atom in G_struc[0].get_residues()][0]
1835
1836
                        r_atoms = [r["O4'"], r["C2'"], r["C1'"]]
1837
                        G_atoms = [G["O4'"], G["C2'"], G["C1'"]]
1838
1839
                        sup = PDB.Superimposer()
1840
                        sup.set_atoms(r_atoms, G_atoms)
1841
                        rms = round(sup.rms, 3)
1842
1843
                        sup.apply(G_struc.get_atoms())  # to all atoms of G
1844
1845
                        r.add(G["N9"])
1846
                        r.add(G["C8"])
1847
                        r.add(G["N7"])
1848
                        r.add(G["C5"])
1849
                        r.add(G["C6"])
1850
                        r.add(G["O6"])
1851
                        r.add(G["N1"])
1852
                        r.add(G["C2"])
1853
                        r.add(G["N2"])
1854
                        r.add(G["N3"])
1855
                        r.add(G["C4"])
1856
1857
                        fixed.append(['add the whole base G', chain.id, r, r.id[1]])
1858
                #
1859
                # fix missing A (the whole base at the moment)
1860
                #
@@ 1861-1889 (lines=29) @@
1858
                #
1859
                # fix missing A (the whole base at the moment)
1860
                #
1861
                if str(r.get_resname()).strip() == "A" and fix_missing_atoms:
1862
                    for a in r:
1863
                        if a.id == "N1":
1864
                            break
1865
                    else:
1866
                        A_struc = PDB.PDBParser().get_structure('', path + '/data/A.pdb')
1867
                        A = [A_atom for A_atom in A_struc[0].get_residues()][0]
1868
1869
                        r_atoms = [r["O4'"], r["C2'"], r["C1'"]]
1870
                        A_atoms = [A["O4'"], A["C2'"], A["C1'"]]
1871
1872
                        sup = PDB.Superimposer()
1873
                        sup.set_atoms(r_atoms, A_atoms)
1874
                        rms = round(sup.rms, 3)
1875
1876
                        sup.apply(A_struc.get_atoms())  # to all atoms of A
1877
1878
                        r.add(A["N9"])
1879
                        r.add(A["C8"])
1880
                        r.add(A["N7"])
1881
                        r.add(A["C5"])
1882
                        r.add(A["C6"])
1883
                        r.add(A["N6"])
1884
                        r.add(A["N1"])
1885
                        r.add(A["C2"])
1886
                        r.add(A["N3"])
1887
                        r.add(A["C4"])
1888
1889
                        fixed.append(['add the whole base A', chain.id, r, r.id[1]])
1890
1891
                #
1892
                # strip residues of extra atoms, not in G_ATOMS in this case