Skip to content

Commit ee1b637

Browse files
committed
rna_pdb_tools: --conect-no-linkage
1 parent 785c146 commit ee1b637

File tree

2 files changed

+16
-8
lines changed

2 files changed

+16
-8
lines changed

rna_tools/rna_pdb_tools.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ def get_parser():
7272

7373
parser.add_argument('--conect', help='add conect to rpr file', action='store_true')
7474

75+
parser.add_argument('--conect-no-linkage', help='dont add conect from our residue to another', action='store_true')
76+
7577
parser.add_argument('--renum-residues-dirty', help='', action='store_true')
7678

7779
parser.add_argument('--undo', help='undo operation of action done --inplace, , rename "backup files" .pdb~ to pdb, ALL files in the folder, not only ~ related to the last action (that you might want to revert, so be careful)', action='store_true')
@@ -527,6 +529,7 @@ def get_parser():
527529
save_single_res=args.save_single_res,
528530
ref_frame_only = args.ref_frame_only,
529531
conect=args.conect,
532+
conect_no_linkage=args.conect_no_linkage,
530533
verbose=args.verbose)
531534

532535
if args.inplace:

rna_tools/rna_tools_lib.py

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
"HIS", "ILE", "LEU", "LYS", "MET", "PHE", "PRO", "SER", "THR",
3636
"TRP", "TYR", "VAL"]
3737

38-
def generate_conect_records(residue_type, shift=0):
38+
def generate_conect_records(residue_type, shift=0, no_junction=True):
3939
"""
4040
Generate CONECT records for an RNA residue (U, A, C, or G).
4141
@@ -70,8 +70,10 @@ def generate_conect_records(residue_type, shift=0):
7070
(19, 20), # C5 -> C6
7171
(20, 13), # C6 -> N1
7272
(7, 12), # O4' -> C1'
73-
(9, 21) # junction
7473
]
74+
if not no_junction:
75+
connections.append((9, 21))
76+
print(connections)
7577
elif residue_type == "A":
7678
connections = [
7779
(1, 2), # P -> OP1
@@ -98,8 +100,9 @@ def generate_conect_records(residue_type, shift=0):
98100
(22, 16), # C4 -> C5
99101
(22, 13), # C4 -> N9
100102
(7, 12), # O4' -> C1'
101-
(9, 23) # junction
102103
]
104+
if not no_junction:
105+
connections.append((9, 23))
103106
elif residue_type == "C":
104107
connections = [
105108
(1, 2), # P -> OP1
@@ -123,8 +126,9 @@ def generate_conect_records(residue_type, shift=0):
123126
(19, 20), # C5 -> C6
124127
(20, 13), # C6 -> N1
125128
(7, 12), # O4' -> C1' (additional connection)
126-
(9, 21) # junction
127129
]
130+
if not no_junction:
131+
connections.append((9, 21))
128132
elif residue_type == "G":
129133
connections = [
130134
(1, 2), # P -> OP1
@@ -152,8 +156,9 @@ def generate_conect_records(residue_type, shift=0):
152156
(23, 16), # C4 -> C5
153157
(23, 13), # C4 -> N9
154158
(7, 12), # O4' -> C1' (additional connection)
155-
(9, 24) # junction
156159
]
160+
if not no_junction:
161+
connections.append((9, 24))
157162
else:
158163
raise ValueError("Invalid residue type. Choose 'U', 'A', 'C', or 'G'.")
159164

@@ -164,8 +169,7 @@ def generate_conect_records(residue_type, shift=0):
164169
# Shift the serial numbers
165170
atom1_serial += shift
166171
atom2_serial += shift
167-
conect_records.append(f"CONECT{atom1_serial:>4}{atom2_serial:>4}")
168-
172+
conect_records.append(f"CONECT{atom1_serial:>5}{atom2_serial:>5}")
169173
return conect_records
170174

171175

@@ -1391,6 +1395,7 @@ def get_rnapuzzle_ready(self, renumber_residues=True, fix_missing_atoms=True,
13911395
p_only = False,
13921396
check_geometry = False,
13931397
conect = False,
1398+
conect_no_linkage = False,
13941399
verbose=False): # :, ready_for="RNAPuzzle"):
13951400
"""Get rnapuzzle (SimRNA) ready structure.
13961401
@@ -1965,7 +1970,7 @@ def get_rnapuzzle_ready(self, renumber_residues=True, fix_missing_atoms=True,
19651970
# add CONET
19661971
if conect:
19671972
ic(atom_index, r2)
1968-
conects.extend(generate_conect_records(r2.get_resname().strip(), atom_index)) # + '\n'
1973+
conects.extend(generate_conect_records(r2.get_resname().strip(), atom_index, conect_no_linkage))
19691974
atom_index += len(r2)
19701975
print(conect)
19711976

0 commit comments

Comments
 (0)