Mercurial > repos > drosofff > sam_to_fastq
comparison sam_to_fastq.py @ 1:c1ab6747fb66 draft
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/sam_to_fastq commit 0651eb8c86d890e4b223fec82ab3980932710030
author | drosofff |
---|---|
date | Mon, 21 Mar 2016 17:32:37 -0400 |
parents | 4c60ceadc414 |
children | de6fd19d1576 |
comparison
equal
deleted
inserted
replaced
0:4c60ceadc414 | 1:c1ab6747fb66 |
---|---|
13 return args | 13 return args |
14 | 14 |
15 | 15 |
16 def print_fastq_sequence(samline, file): | 16 def print_fastq_sequence(samline, file): |
17 samfields = samline[:-1].split("\t") | 17 samfields = samline[:-1].split("\t") |
18 print >> file, '@%s\n%s\n+\n%s' % (samfields[0], samfields[9], samfields[10]) | 18 file.write ( '@%s\n%s\n+\n%s' % (samfields[0], samfields[9], samfields[10]) ) |
19 | 19 |
20 def main(input, output): | 20 def main(input, output): |
21 infile = open (input, "r") | 21 infile = open (input, "r") |
22 outfile = open (output, "w") | 22 outfile = open (output, "w") |
23 for line in infile: | 23 with open (input, "r") as infile: |
24 if line[0] == "@": | 24 with open (output, "w") as outfile: |
25 continue | 25 for line in infile: |
26 if line.split("\t")[1] != "4": | 26 if line[0] == "@": |
27 print_fastq_sequence (line, outfile) | 27 continue |
28 infile.close() | 28 if line.split("\t")[1] != "4": |
29 outfile.close() | 29 print_fastq_sequence (line, outfile) |
30 | 30 |
31 if __name__ == "__main__": | 31 if __name__ == "__main__": |
32 args = Parser() | 32 args = Parser() |
33 main (args.input, args.output) | 33 main (args.input, args.output) |