123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 |
- import pdb
- import sys
- from structure import *
- from chem import *
- import argparse
-
- from datetime import date
-
- def print_dssp(pdb_file, verbose=False, raw_ladd=False):
- # gets export date
- export_date = date.today().strftime("%d/%m/%Y")
-
- ################### OUTPUT ####################
- # print DSSP-style formatted header of PDB file
- print("################### DSSP OUTPUT ####################\n####",
- "Exported on",export_date,
- "\n####################################################")
- for elem in pdb_file.get_header() :
- print(pdb_file.get_header()[elem], end="")
-
- # Get preliminary data for print loop
- residues = pdb_file.residues
- bridges = get_bridges(residues)
- ladders = get_ladders(bridges, residues)
- sheets = get_sheets(ladders)
- helix = build_helix_patterns(residues)
- # iterating over residues
- # print header of table
- print(' # RESIDUE AA STRUCTURE BP1 TCO KAPPA ALPHA ' \
- 'PHI PSI X-CA Y-CA Z-CA')
- for i,res in enumerate(residues):
- #res.get_turns(residues, turns)
- kappa = res.get_bends(residues)[0]
- bend_symbol = res.get_bends(residues)[1]
- t_co = res.get_tco(residues)
- alpha = res.get_chirality(residues)[0]
- chirality = res.get_chirality(residues)[1]
- phi = res.get_phi_psi(residues)[0]
- psi = res.get_phi_psi(residues)[1]
- x_ca = res.atoms["CA"].coord_x
- y_ca = res.atoms["CA"].coord_y
- z_ca = res.atoms["CA"].coord_z
- turns = build_turns_patterns(residues)
- turn_3 = print_turn_pattern(residues, res, turns[0])
- turn_4 = print_turn_pattern(residues, res, turns[1])
- turn_5 = print_turn_pattern(residues, res, turns[2])
- helix_3 = print_helix_pattern(residues, res, helix[0])
- helix_4 = print_helix_pattern(residues, res, helix[1])
- helix_5 = print_helix_pattern(residues, res, helix[2])
- if i in bridges.keys():
- bp1 = bridges[i].j
- else:
- bp1 = 0
-
- print('{0: >5}{1: >5}{2: >2}{3: >2}{4: >2}{5: >2}{6: >2}{7: >2}'\
- '{8: >2}{9: >2}{10: >2}{11: >1}{12: >5}{13: >7}{14: >7}' \
- '{15: >7}{16: >7}{17: >7}{18: >7}{19: >7}'\
- '{20: >7}'.format(i+1, res.resid,
- res.chain_id,
- res.res_letter,
- helix_3, helix_4,
- helix_5, turn_3,
- turn_4, turn_5, bend_symbol,
- chirality, bp1,round(t_co, 3),
- round(kappa,1), round(alpha, 1),
- round(phi, 1), round(psi,1),
- round(x_ca,1), round(y_ca,1),
- round(z_ca,1)))
- if(raw_ladd):
- raw_ladders_print(ladders)
-
- parser = argparse.ArgumentParser()
- if(len(sys.argv)<2):
- print("Not enough arguments! Run with --help to learn more about proper"
- "call structure and parameters.")
- else:
- parser.add_argument("file", type=str, help="input file in PDB format")
- parser.add_argument("-v","--verbose", help="add ladders verbose output",
- action="store_true")
- args = parser.parse_args()
- pdb_file = pdb.PDBFile(sys.argv[1])
- if(args.verbose):
- print_dssp(pdb_file, raw_ladd=True)
- else:
- print_dssp(pdb_file)
-
|