comparison fasta_extract.py @ 7:4f6eba6beef5 draft

Uploaded
author greg
date Sun, 10 Jan 2016 14:25:50 -0500
parents 24769b1ca957
children a3f52920020b
comparison
equal deleted inserted replaced
6:d077d91065ea 7:4f6eba6beef5
18 if consider_strand: 18 if consider_strand:
19 attrs += '_s' 19 attrs += '_s'
20 if orphan: 20 if orphan:
21 attrs += '_orphan' 21 attrs += '_orphan'
22 format = 'gff' 22 format = 'gff'
23 output_dir = 'output_orphan_dir'
23 else: 24 else:
24 format = 'fasta' 25 format = 'fasta'
25 if orphan: 26 output_dir = 'output_dir'
26 return os.path.join('output_orphan_dir', '%s_on_data_%d.%s' % (attrs, hid, format)) 27 return os.path.join(output_dir, '%s_on_data_%d.%s' % (attrs, hid, format))
27 return os.path.join('output_dir', '%s_on_data_%d.%s' % (attrs, hid, format))
28 28
29 29
30 def stop_err(msg): 30 def stop_err(msg):
31 sys.stderr.write(msg) 31 sys.stderr.write(msg)
32 sys.exit(1) 32 sys.exit(1)
42 args = parser.parse_args() 42 args = parser.parse_args()
43 43
44 fasta = Fasta(args.genome_file) 44 fasta = Fasta(args.genome_file)
45 45
46 for (input_filename, hid) in args.inputs: 46 for (input_filename, hid) in args.inputs:
47 hid = int(hid)
48 extend_existing = args.extend_existing == 'existing' 47 extend_existing = args.extend_existing == 'existing'
49 consider_strand = args.strand == 'yes' 48 consider_strand = args.strand == 'yes'
50 reader = csv.reader(open(input_filename, 'rU'), delimiter='\t') 49 reader = csv.reader(open(input_filename, 'rU'), delimiter='\t')
51 fasta_output_path = get_output_path(hid, 50 fasta_output_path = get_output_path(hid,
52 args.subtract_from_start, 51 args.subtract_from_start,
84 output.write('%s\n' % bases) 83 output.write('%s\n' % bases)
85 else: 84 else:
86 orphan_writer.writerow(row) 85 orphan_writer.writerow(row)
87 except Exception, e: 86 except Exception, e:
88 stop_err(str(e)) 87 stop_err(str(e))
88 finally:
89 output.clode()