Skip to content

Commit

Permalink
modified: rna_tools/rna_pdb_inspect.py #141
Browse files Browse the repository at this point in the history
  • Loading branch information
mmagnus committed Jul 27, 2023
1 parent eccf6fd commit 2e03d4c
Showing 1 changed file with 20 additions and 5 deletions.
25 changes: 20 additions & 5 deletions rna_tools/rna_pdb_inspect.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,14 @@ def get_parser():
'C': "P OP1 OP2 O5' C5' C4' O4' C3' O3' C2' O2' C1' N1 C2 O2 N3 C4 N4 C5 C6".split() } # 20

def is_rna_chain(chain):
"""
https://pdb101.rcsb.org/learn/guide-to-understanding-pdb-data/primary-sequences-and-the-pdb-format
"""
AMINOACID_CODES = ["ALA", "ARG", "ASN", "ASP", "CYS", "GLU", "GLN", "GLY",
"HIS", "ILE", "LEU", "LYS", "MET", "PHE", "PRO", "SER", "THR",
"TRP", "TYR", "VAL"]
RES = ['A', 'G', 'U', 'C']
RES = ['A', 'G', 'U', 'C', 'I']
#

aa = []
na = []
Expand All @@ -67,18 +71,27 @@ def is_rna_chain(chain):
print(f'Input: {f}')
r = RNAStructure(f)

print(f'{len(r.get_all_chain_ids())} of chains:', r.get_all_chain_ids())
print(f' {len(r.get_all_chain_ids())} of chains:', ' '.join(r.get_all_chain_ids()))
# get_residue() # even as lines

parser = PDBParser()
struc = parser.get_structure('', f)
rnas = []
for model in struc:
for chain in model:
if is_rna_chain(chain):
rnas.append(chain.id)
else:
#rnas.append(chain.id)
pass

print(f' {len(rnas)} of RNA chains: ' + ' '.join(rnas))
for model in struc:
for chain in model:
print(f' {chain.id} of RNA? {is_rna_chain(chain)}')
if is_rna_chain(chain):
# is it protein?
for res in chain:
#print(f' {res.get_resname()} {res}')

rtype = res.get_resname()
for i, a in enumerate(res):
try:
Expand All @@ -88,4 +101,6 @@ def is_rna_chain(chain):
pass
else:
if res_std[rtype][i] != a.id:
print(f' !wrong order of atoms in residue ! {res_std[rtype][i]} {a.id}')
# print(f' {res.get_resname()} {res}')
print(f' wrong atom order in residue of chain {chain.id} resid {res.id[1]} {res_std[rtype][i]} {a.id}')

0 comments on commit 2e03d4c

Please sign in to comment.