if os.path.exists(sys.argv[2]): print "path exists" else : os.mkdir(sys.argv[2]) for id in open(sys.argv[1]): id = id.strip() line = id if id == "": continue words = line.strip().split('\t') id = words[0] s1 = url_template.format(words[0],words[1],words[2]) sys.stdout.write("Fetching %s..." % id) sys.stdout.flush() gbk_out_file = os.path.join(sys.argv[2], id +words[1]+ ".fa") if os.path.exists(gbk_out_file): print "already fetched" else : seq = urllib2.urlopen(s1).read() if(words[3] == "minus"): seq = reverse_complement.get_from_url(seq) open(gbk_out_file, "w").write(seq) print "Done" time.sleep(1.0/3)
if os.path.exists(sys.argv[2]): print "path exists" else: os.mkdir(sys.argv[2]) for id in open(sys.argv[1]): id = id.strip() line = id if id == "": continue words = line.strip().split('\t') id = words[0] s1 = url_template.format(words[0], words[1], words[2]) sys.stdout.write("Fetching %s..." % id) sys.stdout.flush() gbk_out_file = os.path.join(sys.argv[2], id + words[1] + ".fa") if os.path.exists(gbk_out_file): print "already fetched" else: seq = urllib2.urlopen(s1).read() if (words[3] == "minus" or words[3] == "-"): seq = reverse_complement.get_from_url(seq) open(gbk_out_file, "w").write(seq) print "Done" time.sleep(1.0 / 3)
#!/usr/bin/python import sys sys.path.append('./utils') import reverse_complement seq = "ATGCTat" print seq print reverse_complement.get_rc(seq) seq_url = ">name\nATGTatn" print seq_url print reverse_complement.get_from_url(seq_url)