Mercurial > repos > sanbi-uwc > assess_poliovirus_alignment
comparison assess_alignment.py @ 5:0e556a3f85d6 draft
planemo upload for repository https://github.com/pvanheus/polio_report commit a99e10fec2fac5aae70974c977eb3b362a1a8429-dirty
author | sanbi-uwc |
---|---|
date | Wed, 14 Sep 2022 09:21:44 +0000 |
parents | 1897677e107c |
children | 9fd6dde72d2e |
comparison
equal
deleted
inserted
replaced
4:1897677e107c | 5:0e556a3f85d6 |
---|---|
143 | 143 |
144 | 144 |
145 if __name__ == "__main__": | 145 if __name__ == "__main__": |
146 parser = argparse.ArgumentParser() | 146 parser = argparse.ArgumentParser() |
147 parser.add_argument("--output_filename", help="Path to output file") | 147 parser.add_argument("--output_filename", help="Path to output file") |
148 parser.add_argument("--consensus_output_filename", help="Path to output file for best consensus") | |
148 parser.add_argument("--sample_name", help="Name of sample being analysed") | 149 parser.add_argument("--sample_name", help="Name of sample being analysed") |
149 parser.add_argument( | 150 parser.add_argument( |
150 "--dataset_names", type=comma_split, help="Comma separated names for datasets" | 151 "--dataset_names", type=comma_split, help="Comma separated names for datasets" |
151 ) | 152 ) |
152 parser.add_argument("--datasets", nargs="+") | 153 parser.add_argument("--datasets", nargs="+") |
154 parser.add_argument("--consensi", nargs="+") | |
153 args = parser.parse_args() | 155 args = parser.parse_args() |
154 | 156 |
155 offsets = { | 157 offsets = { |
156 # these are in 0-based coordinates, so off-by-one from NCBI 1-based coordinates | 158 # these are in 0-based coordinates, so off-by-one from NCBI 1-based coordinates |
157 "poliovirus1sabin": 2479, # V01150 | 159 "poliovirus1sabin": 2479, # V01150 |
180 if min_mismatches is None or mismatches < min_mismatches: | 182 if min_mismatches is None or mismatches < min_mismatches: |
181 min_mismatches = mismatches | 183 min_mismatches = mismatches |
182 best_match_mismatch_list = mismatch_list | 184 best_match_mismatch_list = mismatch_list |
183 best_match_quality = quality | 185 best_match_quality = quality |
184 best_match_reference = dataset_name | 186 best_match_reference = dataset_name |
187 best_consensus = args.consensi[file_index] | |
185 percent_mismatches = round(min_mismatches / lengths[best_match_reference] * 100, 2) | 188 percent_mismatches = round(min_mismatches / lengths[best_match_reference] * 100, 2) |
186 | 189 |
187 info = { | 190 info = { |
188 "sample_name": args.sample_name, | 191 "sample_name": args.sample_name, |
189 "best_reference": best_match_reference, | 192 "best_reference": best_match_reference, |
190 "mismatches": min_mismatches, | 193 "mismatches": min_mismatches, |
191 "mismatch_list": best_match_mismatch_list, | 194 "mismatch_list": best_match_mismatch_list, |
192 "quality": best_match_quality, | 195 "quality": best_match_quality, |
193 "perc_mismatches": percent_mismatches | 196 "perc_mismatches": percent_mismatches, |
194 } | 197 } |
195 json.dump(info, open(args.output_filename, "w")) | 198 json.dump(info, open(args.output_filename, "w")) |
199 | |
200 open(args.consensus_output_filename, "w").write(best_consensus) |