Rosetta
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
calibur.py
Go to the documentation of this file.
1 #!/usr/bin/python
2 
3 # (c) Copyright Rosetta Commons Member Institutions.
4 # (c) This file is part of the Rosetta software suite and is made available under license.
5 # (c) The Rosetta software is developed by the contributing members of the Rosetta Commons.
6 # (c) For more information, see http://www.rosettacommons.org. Questions about this can be
7 # (c) addressed to University of Washington UW TechTransfer, email: license@u.washington.edu.
8 
9 ## @file /GUIs/pyrosetta_toolkit/modules/calibur.py
10 ## @brief Functions for running and parsing calibur.
11 ## @author Jared Adolf-Bryfogle (jadolfbr@gmail.com)
12 
13 #Python Imports
14 import sys
15 import os
16 import re
17 
18 class calibur:
19  def __init__(self, caliburPath=set):
20  """
21  This is meant to be a set of functions for running and parsing calibur
22  Uses system path, or specified path in calculations.
23  Calibur path should be in PATH, or specified upon construction.
24  """
25 
26  if caliburPath ==set:
27  self.caliburPath = "calibur"
28  else:
29  self.caliburPath = caliburPath
30 
31  def run_calibur(self, PDBLIST_Path, chain=False, Nter=False, Cter=False, threshold=0):
32  """
33  Nter, Cter are not residue numbering - pretty much it is rosetta numbering as far as I can tell...
34  Need to do this better with option type thing..
35  """
36  run = self.caliburPath
37  if chain:
38  run = run+" -c "+chain
39  if Nter:
40  run = run+" -r "+repr(Nter)+','+repr(Cter)
41  run = run+' '+PDBLIST_Path
42  if threshold !=0:
43  run = run+ ' -t '+repr(threshold)
44  self.output = os.popen(run).readlines()
45  print "Calibur Completed..."
46  return
47 
48  def ret_centers(self):
49  """
50  return array of top 2 clusters, and a corresponding array of sizes.
51  """
52  found = False
53  for line in self.output:
54  print line
55  if re.search("Largest 2 clusters", line):
56  clusline = line.strip()
57  found = True
58  break
59 
60  #First, parse by :
61  if not found:
62  print "Clustering failed..."
63  return
64 
65  sp1 = clusline.split(":")
66 
67  sp2 = sp1[1].split(",")
68  paths = []; neighbors = []
69  for pdb in sp2:
70  sp3 = pdb.split("(")
71  paths.append(sp3[0])
72  neighbors.append(int(sp3[1].split(")")[0]))
73 
74  return paths, neighbors
75 
76  def ret_threshold(self):
77  """
78  Returns threshold used in analysis.
79  """
80 
81  for line in self.output:
82  if re.search("Threshold = ", line):
83  sp = line.split(" = ")
84 
85  return sp[1].strip()
86 
87 
88  def save_neighbors(self, resultsPath, center):
89  pass
90 
91  def ret_neighbors(self, resultsPath):
92  pass
93 
95  pass
97  pass
98 
99 
utility::vector1< std::string > split(const std::string &s)
split given std::string using ' ' symbol.
Definition: string_util.cc:59
std::string & strip(std::string &s, std::string const &chars)
Strip Specified Characters from a string's Tails.