Code Duplication    Length = 29-30 lines in 2 locations

rna_tools/rna_tools_lib.py 2 locations

@@ 1630-1659 (lines=30) @@
1627
                #
1628
                # fix missing G (the whole base at the moment)
1629
                #
1630
                if str(r.get_resname()).strip() == "G" and fix_missing_atoms:
1631
                    for a in r:
1632
                        if a.id == "N1":
1633
                            break
1634
                    else:
1635
                        G_struc = PDB.PDBParser().get_structure('', path + '/data/G.pdb')
1636
                        G = [G_atom for G_atom in G_struc[0].get_residues()][0]
1637
1638
                        r_atoms = [r["O4'"], r["C2'"], r["C1'"]]
1639
                        G_atoms = [G["O4'"], G["C2'"], G["C1'"]]
1640
1641
                        sup = PDB.Superimposer()
1642
                        sup.set_atoms(r_atoms, G_atoms)
1643
                        rms = round(sup.rms, 3)
1644
1645
                        sup.apply(G_struc.get_atoms())  # to all atoms of G
1646
1647
                        r.add(G["N9"])
1648
                        r.add(G["C8"])
1649
                        r.add(G["N7"])
1650
                        r.add(G["C5"])
1651
                        r.add(G["C6"])
1652
                        r.add(G["O6"])
1653
                        r.add(G["N1"])
1654
                        r.add(G["C2"])
1655
                        r.add(G["N2"])
1656
                        r.add(G["N3"])
1657
                        r.add(G["C4"])
1658
1659
                        fixed.append(['add the whole base G', chain.id, r, r.id[1]])
1660
                #
1661
                # fix missing A (the whole base at the moment)
1662
                #
@@ 1663-1691 (lines=29) @@
1660
                #
1661
                # fix missing A (the whole base at the moment)
1662
                #
1663
                if str(r.get_resname()).strip() == "A" and fix_missing_atoms:
1664
                    for a in r:
1665
                        if a.id == "N1":
1666
                            break
1667
                    else:
1668
                        A_struc = PDB.PDBParser().get_structure('', path + '/data/A.pdb')
1669
                        A = [A_atom for A_atom in A_struc[0].get_residues()][0]
1670
1671
                        r_atoms = [r["O4'"], r["C2'"], r["C1'"]]
1672
                        A_atoms = [A["O4'"], A["C2'"], A["C1'"]]
1673
1674
                        sup = PDB.Superimposer()
1675
                        sup.set_atoms(r_atoms, A_atoms)
1676
                        rms = round(sup.rms, 3)
1677
1678
                        sup.apply(A_struc.get_atoms())  # to all atoms of A
1679
1680
                        r.add(A["N9"])
1681
                        r.add(A["C8"])
1682
                        r.add(A["N7"])
1683
                        r.add(A["C5"])
1684
                        r.add(A["C6"])
1685
                        r.add(A["N6"])
1686
                        r.add(A["N1"])
1687
                        r.add(A["C2"])
1688
                        r.add(A["N3"])
1689
                        r.add(A["C4"])
1690
1691
                        fixed.append(['add the whole base A', chain.id, r, r.id[1]])
1692
1693
                #
1694
                # strip residues of extra atoms, not in G_ATOMS in this case