Mercurial > repos > mheinzl > variant_analyzer2
comparison mut2read.py @ 84:e46d5e377760 draft
planemo upload for repository https://github.com/Single-Molecule-Genetics/VariantAnalyzerGalaxy/tree/master/tools/variant_analyzer commit ee4a8e6cf290e6c8a4d55f9cd2839d60ab3b11c8-dirty
author | mheinzl |
---|---|
date | Fri, 19 Aug 2022 11:23:37 +0000 |
parents | fdfe9a919ff7 |
children |
comparison
equal
deleted
inserted
replaced
83:8cec772c0bf1 | 84:e46d5e377760 |
---|---|
38 help='TABULAR file with aligned families.') | 38 help='TABULAR file with aligned families.') |
39 parser.add_argument('--outputFastq', | 39 parser.add_argument('--outputFastq', |
40 help='Output FASTQ file of reads with mutations.') | 40 help='Output FASTQ file of reads with mutations.') |
41 parser.add_argument('--outputJson', | 41 parser.add_argument('--outputJson', |
42 help='Output JSON file to store collected data.') | 42 help='Output JSON file to store collected data.') |
43 parser.add_argument('--refalttiers', action="store_true", | |
44 help='Store also information about the reference allele.') | |
43 return parser | 45 return parser |
44 | 46 |
45 | 47 |
46 def mut2read(argv): | 48 def mut2read(argv): |
47 parser = make_argparser() | 49 parser = make_argparser() |
50 file1 = args.mutFile | 52 file1 = args.mutFile |
51 file2 = args.bamFile | 53 file2 = args.bamFile |
52 file3 = args.familiesFile | 54 file3 = args.familiesFile |
53 outfile = args.outputFastq | 55 outfile = args.outputFastq |
54 json_file = args.outputJson | 56 json_file = args.outputJson |
57 refalttiers = args.refalttiers | |
55 | 58 |
56 if os.path.isfile(file1) is False: | 59 if os.path.isfile(file1) is False: |
57 sys.exit("Error: Could not find '{}'".format(file1)) | 60 sys.exit("Error: Could not find '{}'".format(file1)) |
58 | 61 |
59 if os.path.isfile(file2) is False: | 62 if os.path.isfile(file2) is False: |
187 with open(file3, 'r') as families: | 190 with open(file3, 'r') as families: |
188 for line in families: | 191 for line in families: |
189 line = line.rstrip('\n') | 192 line = line.rstrip('\n') |
190 splits = line.split('\t') | 193 splits = line.split('\t') |
191 tag = splits[0] | 194 tag = splits[0] |
192 | 195 if refalttiers is True: |
193 if tag in tag_dict or tag in tag_dict_ref: | 196 if tag in tag_dict or tag in tag_dict_ref: |
194 str1 = splits[4] | 197 str1 = splits[4] |
195 curr_seq = str1.replace("-", "") | 198 curr_seq = str1.replace("-", "") |
196 str2 = splits[5] | 199 str2 = splits[5] |
197 curr_qual = str2.replace(" ", "") | 200 curr_qual = str2.replace(" ", "") |
198 out.write("@" + splits[0] + "." + splits[1] + "." + splits[2] + "\n") | 201 out.write("@" + splits[0] + "." + splits[1] + "." + splits[2] + "\n") |
199 out.write(curr_seq + "\n") | 202 out.write(curr_seq + "\n") |
200 out.write("+" + "\n") | 203 out.write("+" + "\n") |
201 out.write(curr_qual + "\n") | 204 out.write(curr_qual + "\n") |
205 else: | |
206 if tag in tag_dict: | |
207 str1 = splits[4] | |
208 curr_seq = str1.replace("-", "") | |
209 str2 = splits[5] | |
210 curr_qual = str2.replace(" ", "") | |
211 out.write("@" + splits[0] + "." + splits[1] + "." + splits[2] + "\n") | |
212 out.write(curr_seq + "\n") | |
213 out.write("+" + "\n") | |
214 out.write(curr_qual + "\n") | |
202 | 215 |
203 | 216 |
204 if __name__ == '__main__': | 217 if __name__ == '__main__': |
205 sys.exit(mut2read(sys.argv)) | 218 sys.exit(mut2read(sys.argv)) |