Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Refactoring of main.py.

  • Loading branch information...
commit d152cd354186f7209a8712fafcf9df636a15c97c 1 parent 262a6c8
@andersx andersx authored
View
14 INSTALL
@@ -1,10 +1,16 @@
-== REQUIREMENTS ==
+=== REQUIREMENTS: ===
- * Python
+ * Python version 2.x
* Numpy
* Biopython
-== INSTALLATION ==
+ Tested on:
+ - Ubuntu 10.04 LTS
+ - CentOS 6.3
+
+=== INSTALLATION: ===
+
+ No installation needed.
+
- No installation is needed.
View
2  LICENSE
@@ -1,4 +1,4 @@
-Copyright (c) 2012 Anders S. Christensen
+Copyright (c) 2012 Anders S. Christensen, Maher Channir
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
View
16 README.md
@@ -1,4 +1,14 @@
-PROCS
-=====
-
A Protein Chemical Shift Predictor
+
+
+Usage: (example)
+
+ $ ./execute 1CEX.pdb
+
+
+
+
+BUGS + SUPPORT:
+
+ Report bugs to: andersx@nano.ku.dk
+
View
8 execute
@@ -1,5 +1,5 @@
#!/usr/bin/python
-
+#
# Copyright (c) 2012 Anders S. Christensen
#
# This program is free software; you can redistribute it and/or modify
@@ -17,10 +17,6 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA.
-
-import sys
from main import main
-pdb_filename = sys.argv[1]
-
-main(pdb_filename)
+main()
View
42 main.py
@@ -16,11 +16,9 @@
# 02110-1301, USA.
import structure_tools as struct
+import sys
-def main(pdb_filename):
- # Load chain (as Bio.PDB chain-type) from pdb-file
- chain = struct.load_chain(pdb_filename)
-
+def calculate_chemical_shifts(chain):
# Calculate all phi/psi angles once
phi_psi_angles = struct.get_phi_psi_angles(chain)
@@ -36,8 +34,34 @@ def main(pdb_filename):
res_id = residue.id[1]
res_name = residue.get_resname()
- print res_name, res_id, phi_psi_angles[res_id], chi_angles[res_id]
-
- # for atom in residue:
- # print atom
-
+ # Do something ...
+ #
+ # print res_name, res_id, phi_psi_angles[res_id], chi_angles[res_id]
+
+
+ # Retur something ...
+ return []
+
+
+
+def main():
+
+ try:
+ pdb_filename = sys.argv[1]
+
+ # Load chain (as Bio.PDB chain-type) from pdb-file
+ chain = struct.load_chain(pdb_filename)
+ print 'Loaded chain from file:', pdb_filename
+
+ except:
+ print 'ERROR: Problem loading chain from file:', pdb_filename
+ raise SystemExit
+
+
+ # Calculate chemical shifts
+ chemical_shifts = calculate_chemical_shifts(chain)
+
+
+
+
+
View
24 structure_tools.py
@@ -16,10 +16,10 @@
# 02110-1301, USA.
import numpy
-from Bio.PDB import *
+import Bio.PDB
-# Atoms in the chain that forms chi1, chi2, etc. dihedral angles
+# Atoms in the chain that form chi1, chi2, etc. dihedral angles
SIDE_CHAINS = {'ALA' : [],
'GLY' : [],
'ARG' : ['N', 'CA', 'CB', 'CG', 'CD', 'NE', 'CZ'],
@@ -30,15 +30,15 @@
'GLN' : ['N', 'CA', 'CB', 'CG', 'CD', 'OE1'],
'HIS' : ['N', 'CA', 'CB', 'CG', 'CD2'],
'ILE' : ['N', 'CA', 'CB', 'CG1', 'CD1'],
- 'LEU' : ['N', 'CA', 'CB', 'CG', 'CD1'],
+ 'LEU' : ['N', 'CA', 'CB', 'CG', 'CD1'],
'LYS' : ['N', 'CA', 'CB', 'CG', 'CD', 'CE', 'NZ'],
'MET' : ['N', 'CA', 'CB', 'CG', 'SD', 'CE'],
'PHE' : ['N', 'CA', 'CB', 'CG', 'CD1'],
'PRO' : ['N', 'CA', 'CB', 'CG', 'CD'],
'SER' : ['N', 'CA', 'CB', 'OG'],
'THR' : ['N', 'CA', 'CB', 'OG1'],
- 'TYR' : ['N', 'CA', 'CB', 'CG', 'CD1'],
- 'TRP' : ['N', 'CA', 'CB', 'CG', 'CD1'],
+ 'TYR' : ['N', 'CA', 'CB', 'CG', 'CD1'],
+ 'TRP' : ['N', 'CA', 'CB', 'CG', 'CD1'],
'VAL' : ['N', 'CA', 'CB', 'CG1']}
# Atoms that form aromatic rings.
@@ -61,10 +61,10 @@ def calculate_chi_angles(residue):
for i in range(len(atoms) - 3):
try:
- this_chi = calc_dihedral(residue[atoms[0 + i]].get_vector(),
- residue[atoms[1 + i]].get_vector(),
- residue[atoms[2 + i]].get_vector(),
- residue[atoms[3 + i]].get_vector())
+ this_chi = Bio.PDB.calc_dihedral(residue[atoms[0 + i]].get_vector(),
+ residue[atoms[1 + i]].get_vector(),
+ residue[atoms[2 + i]].get_vector(),
+ residue[atoms[3 + i]].get_vector())
except:
print "Error: Missing atoms in side chain of ",
print residue.get_resname(), residue.id[1]
@@ -79,8 +79,8 @@ def calculate_chi_angles(residue):
# Return a dictionary of lists of phi/psi-angles for each residues
def get_phi_psi_angles(chain):
- # Use method from biopython to extract phi/psi angles
- polypeptide = Polypeptide.Polypeptide(chain)
+ # Use method from Biopython/Bio.PDB to extract phi/psi angles
+ polypeptide = Bio.PDB.Polypeptide.Polypeptide(chain)
phi_psi_disordered_list = polypeptide.get_phi_psi_list()
phi_psi_dictionary = dict()
@@ -110,7 +110,7 @@ def get_chi_angles(chain):
# Load first chain of first model found in the pdb-file
def load_chain(filename):
- for model in PDBParser().get_structure("chain", filename) :
+ for model in Bio.PDB.PDBParser().get_structure("chain", filename) :
for chain in model:
return chain
Please sign in to comment.
Something went wrong with that request. Please try again.