Back to index

python-biopython  1.60
Functions | Variables
scop_pdb Namespace Reference

Functions

def usage
def open_pdb
def main

Variables

string default_pdb_url = "http://www.rcsb.org/pdb/cgi/export.cgi/somefile.pdb?"

Function Documentation

def scop_pdb.main ( )

Definition at line 71 of file scop_pdb.py.

00071 
00072 def main():
00073     try:
00074         opts, args = getopt.getopt(sys.argv[1:], "hp:o:i:",
00075              ["help", "usage","pdb=","output=","input="])
00076     except getopt.GetoptError:
00077         # print help information and exit:
00078         usage()
00079         sys.exit(2)
00080 
00081     input= None
00082     in_handle = None
00083     output = None
00084     pdb_url = None
00085     cla_url = None
00086     raf_url = None
00087     
00088     for o, a in opts:
00089         if o in ("-h", "--help","--usage"):
00090             usage()
00091             sys.exit()
00092         elif o in ("-o", "--output"):
00093             output = a
00094         elif o in ("-i", "--input"):
00095             input = a
00096         elif o in ("-p", "--pdb"):
00097             pdb_url = a
00098 
00099     if len(args) <2 :
00100         print >>sys.stderr, \
00101              "Not enough arguments. Try --help for more details."
00102         sys.exit(2)
00103 
00104     raf_url = args[0]
00105     cla_url = args[1]
00106     
00107     (raf_filename, headers) = urllib.urlretrieve(raf_url)
00108     seqMapIndex = Raf.SeqMapIndex(raf_filename)
00109 
00110     (cla_filename, headers) = urllib.urlretrieve(cla_url)
00111     claIndex = Cla.Index(cla_filename)
00112 
00113     if input == None :
00114         sids = args[2:]
00115     elif input == '-' :
00116         sids = sys.stdin.xreadlines()
00117     else :
00118         in_handle = open(input)
00119         sids = in_handle.xreadlines()
00120 
00121     try:
00122         for sid in sids :
00123             if not sid or sid[0:1]=='#': continue
00124             id = sid[0:7]
00125             pdbid=id[1:5]
00126             s = pdbid[0:1]
00127             if s=='0' or s=='s' :
00128                 print >>sys.stderr,"No coordinates for domain "+id
00129                 continue
00130 
00131             if output == None :
00132                 filename = id+".ent"
00133                 out_handle = open(filename, "w+")
00134             elif output == '-' :
00135                 out_handle = sys.stdout
00136             else :
00137                 out_handle = open(output, "w+")
00138                 
00139             try:
00140                 try:
00141                     claRec = claIndex[id]
00142                     residues = claRec.residues
00143                     seqMap = seqMapIndex.getSeqMap(residues)
00144                     pdbid = residues.pdbid
00145 
00146                     f = open_pdb(pdbid, pdb_url) 
00147                     try:
00148                         seqMap.getAtoms(f, out_handle)
00149                     finally :
00150                         f.close()
00151                 except (IOError, KeyError, RuntimeError), e:
00152                     print >>sys.stderr, "I cannot do SCOP domain ",id,":",e
00153             finally :
00154                 out_handle.close()
00155     finally :
00156         if in_handle != None :
00157             in_handle.close()
00158                 
                

Here is the call graph for this function:

def scop_pdb.open_pdb (   pdbid,
  pdb_url = None 
)

Definition at line 64 of file scop_pdb.py.

00064 
00065 def open_pdb(pdbid, pdb_url=None) :
00066     if pdb_url ==None: pdb_url = default_pdb_url
00067     url = pdb_url % pdbid
00068     fn, header = urllib.urlretrieve(url)
00069     return open(fn)
00070 

Here is the call graph for this function:

Here is the caller graph for this function:

def scop_pdb.usage ( )

Definition at line 16 of file scop_pdb.py.

00016 
00017 def usage() :
00018     print \
00019 """Extract a SCOP domain's ATOM and HETATOM records from the relevant PDB file.
00020 
00021 For example:
00022   scop_pdb.py astral-rapid-access-1.55.raf dir.cla.scop.txt_1.55 d3hbib_
00023 
00024 A result file, d3hbib_.ent, will be generated in the working directory.
00025 
00026 The required RAF file can be found at [http://astral.stanford.edu/raf.html],
00027 and the SCOP CLA file at [http://scop.berkeley.edu/parse/index.html].
00028 
00029 Note: Errors will occur if the PDB file has been altered since the creation
00030 of the SCOP CLA and ASTRAL RAF files.
00031  
00032 Usage: scop_pdb [-h] [-i file] [-o file] [-p pdb_url_prefix]
00033                  raf_url cla_url [sid] [sid] [sid] ...
00034 
00035  -h        -- Print this help message.
00036 
00037  -i file   -- Input file name. Each line should start with an sid (Scop domain
00038               identifier). Blank lines, and lines starting with '#' are
00039               ignored. If file is '-' then data is read from stdin. If not
00040               given then sids are taken from the command line. 
00041 
00042  -o file   -- Output file name. If '-' then data is written to stdout. If not
00043               given then data is written to files named sid+'.ent'.
00044 
00045  -p pdb_url-- A URL for PDB files. The token '%s' will be replaced with the
00046               4 character PDB ID. If the pdb_url is not given then the latest
00047               PDB file is retrieved directly from rcsb.org.
00048 
00049 
00050   raf_url  -- The URL or filename of an ASTRAL Rapid Access File sequence map.
00051               See [http://astral.stanford.edu/raf.html]
00052 
00053   cla_url  -- The URL or filename of a SCOP parsable CLA file.
00054               See [http://scop.berkeley.edu/parse/index.html]
00055 
00056   sid      -- A SCOP domain identifier. e.g. d3hbib_ 
00057 """
00058 
00059 

Here is the caller graph for this function:


Variable Documentation

string scop_pdb.default_pdb_url = "http://www.rcsb.org/pdb/cgi/export.cgi/somefile.pdb?"

Definition at line 60 of file scop_pdb.py.