def parse_results( args ): dict = {} count = 0 for file in args.results_fn: with open( file, "r" ) as f: #print file for l in f: ls = l.split() try: rsn = int( ls[2].replace(",","") ) except ValueError: # if total_score < 0 break rmsd = float( ls[4].replace(",","") ) fragid = ls[7] if fragid == "null": continue fragid = Util.extract_fragid( ls[7] ) if dict.has_key( rsn ): if dict[ rsn ].has_key( fragid ): dict[ rsn ][ fragid ][0] += 1 else: dict[ rsn ][ fragid ] = [ 1, rmsd ] else: dict[ rsn ] = { fragid : [ 1, rmsd ] } count += 1 return dict, count
def get_frag_xyzMatx(fragfiles, frags_dir): """ return a dict[ fragid ] = len*3 xyz numpy array """ dict = {} for frag in fragfiles: # print frag = frag.split("????.pdb")[0] # print frag frag_fn = glob(frags_dir + "/%s*pdb" % frag) # print frag_fn assert len(frag_fn) == 1, frag_fn fragid = Util.extract_fragid(basename(frag_fn[0])) dict[fragid] = get_CA_matx(frag_fn[0]) return dict
def parse_results(args): """ read through all the mc_results files return a dict[ rsn ] = { fragid: [ count, rmsd ], fragid2: [ count, rmsd ] ... } """ dict = {} fragfiles = [] count = 0 for file in args.mc_results_fn: with open(file, "r") as f: # print file for l in f: ls = l.split() try: rsn = int(ls[2].replace(",", "")) except ValueError: # if total_score < 0 break rmsd = float(ls[4].replace(",", "")) fragid = ls[7] if fragid == "null": continue fragfiles.append(fragid) fragid = Util.extract_fragid(ls[7]) if dict.has_key(rsn): if dict[rsn].has_key(fragid): dict[rsn][fragid][0] += 1 else: dict[rsn][fragid] = [1, rmsd] else: dict[rsn] = {fragid: [1, rmsd]} count += 1 fragfiles = list(set(fragfiles)) # print fragfiles return dict, fragfiles, count # total number of lines
def fragfn_to_pos( self, fragfile ): pos = Util.extract_fragid( fragfile )[1] return pos # it's int