comparison format_fasta_hairpins.py @ 13:b045c30fb768 draft

"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit af48e9f6df2717ffd3731a974be1ec36e4eff779"
author artbio
date Fri, 18 Oct 2019 19:18:50 -0400
parents de227b7307cf
children
comparison
equal deleted inserted replaced
12:6d3e98cba73a 13:b045c30fb768
41 41
42 42
43 def convert_and_print_hairpins(gzipfile, basename, fasta_output): 43 def convert_and_print_hairpins(gzipfile, basename, fasta_output):
44 raw_fasta_dict = get_fasta_dic(gzipfile) 44 raw_fasta_dict = get_fasta_dic(gzipfile)
45 parsed_fasta_dict = {} 45 parsed_fasta_dict = {}
46 trs = str.maketrans("uU", "tT")
47 for head in raw_fasta_dict: 46 for head in raw_fasta_dict:
48 if basename in head: 47 if basename in head:
49 parsed_fasta_dict[head] = raw_fasta_dict[head].translate(trs) 48 parsed_fasta_dict[head] = raw_fasta_dict[head]
49 parsed_fasta_dict[head] = ''.join(
50 [i if i != 'u' else 't' for i in parsed_fasta_dict[head]])
51 parsed_fasta_dict[head] = ''.join(
52 [i if i != 'U' else 'T' for i in parsed_fasta_dict[head]])
50 with open(fasta_output, "w") as output: 53 with open(fasta_output, "w") as output:
51 for head in sorted(parsed_fasta_dict): 54 for head in sorted(parsed_fasta_dict):
52 output.write('>%s\n%s\n' % (head, parsed_fasta_dict[head])) 55 output.write('>%s\n%s\n' % (head, parsed_fasta_dict[head]))
53 56
54 57