def testIndex(self) : index = Cla.Index(self.filename) assert len(index)==14 assert index.has_key('d4hbia_') rec = index['d1hbia_'] assert rec.sunid == 14996
def testIndex(self): """Test CLA file indexing.""" index = Cla.Index(self.filename) self.assertEqual(len(index), 14) self.assertIn("d4hbia_", index) rec = index["d1hbia_"] self.assertEqual(rec.sunid, 14996)
def testIndex(self): """Test CLA file indexing""" index = Cla.Index(self.filename) self.assertEqual(len(index), 14) self.assertTrue('d4hbia_' in index) rec = index['d1hbia_'] self.assertEqual(rec.sunid, 14996)
def main(): try: opts, args = getopt.getopt( sys.argv[1:], "hp:o:i:", ["help", "usage", "pdb=", "output=", "input="]) except getopt.GetoptError: # show help information and exit: usage() sys.exit(2) input = None in_handle = None output = None pdb_url = None cla_url = None raf_url = None for o, a in opts: if o in ("-h", "--help", "--usage"): usage() sys.exit() elif o in ("-o", "--output"): output = a elif o in ("-i", "--input"): input = a elif o in ("-p", "--pdb"): pdb_url = a if len(args) < 2: sys.stderr.write( "Not enough arguments. Try --help for more details.\n") sys.exit(2) raf_url = args[0] cla_url = args[1] (raf_filename, headers) = _urlretrieve(raf_url) seqMapIndex = Raf.SeqMapIndex(raf_filename) (cla_filename, headers) = _urlretrieve(cla_url) claIndex = Cla.Index(cla_filename) if input is None: sids = args[2:] elif input == '-': sids = sys.stdin else: in_handle = open(input) sids = in_handle try: for sid in sids: if not sid or sid[0:1] == '#': continue id = sid[0:7] pdbid = id[1:5] s = pdbid[0:1] if s == '0' or s == 's': sys.stderr.write("No coordinates for domain %s\n" % id) continue if output is None: filename = id + ".ent" out_handle = open(filename, "w+") elif output == '-': out_handle = sys.stdout else: out_handle = open(output, "w+") try: try: claRec = claIndex[id] residues = claRec.residues seqMap = seqMapIndex.getSeqMap(residues) pdbid = residues.pdbid f = open_pdb(pdbid, pdb_url) try: seqMap.getAtoms(f, out_handle) finally: f.close() except (IOError, KeyError, RuntimeError) as e: sys.stderr.write("I cannot do SCOP domain %s : %s\n" % (id, e)) finally: out_handle.close() finally: if in_handle is not None: in_handle.close()