if __name__ == "__main__": parser = ArgumentParser() parser.add_argument("-f", "--fragfiles", nargs="+", required=True, help="") parser.add_argument("--outfile", required=True, help="") parser.add_argument("--debug", action="store_true", help="") opts = parser.parse_args() # read into fragment as frag[pos] = fragments offset = 0 out_fraglines = "" for fragfile in opts.fragfiles: print fragfile frag_dict = frag_util.read_fragfile( fragfile ) fraglen = frag_util.get_fraglen( frag_dict ) for pos in frag_dict.keys(): frags = frag_dict[ pos ] nbrs = sorted( frags.keys() ) for nbr in nbrs: l = frags[nbr] if nbr == 0: assert l.startswith("position:") n_nbrs = l.split()[3] out_fraglines += "position:%13s neighbors:%13s\n\n" %( pos+offset, n_nbrs) continue out_fraglines += "%s\n\n" % l offset += (pos+fraglen-1)
#!/usr/bin/env python2.7 from argparse import ArgumentParser from sys import exit, stderr, stdout from os import system from os.path import basename import frag_util if __name__ == "__main__": parser = ArgumentParser() parser.add_argument("-f", "--fragfile", required=True, help="") parser.add_argument("-t", "--top", default=25, type=int, help="") opts = parser.parse_args() frag_dict = frag_util.read_fragfile(opts.fragfile) for pos in frag_dict.keys(): for nbr in range(0, len(frag_dict[pos].keys())): l = frag_dict[pos][nbr] if nbr <= opts.top: if l.startswith("position:"): print "position:%13s neighbors:%13s\n" % (pos, opts.top) continue print l + "\n"