Mercurial > repos > dave > abayesqr
changeset 1:3e9704b9d49e draft
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/abayesqr commit f009487e8fec49f10396185ffd2fc4fe65bf4f29-dirty
author | dave |
---|---|
date | Wed, 20 Mar 2019 13:08:41 -0400 |
parents | 1b624d47d935 |
children | d2aa2a22721d |
files | abayesqr.xml parse_output.py |
diffstat | 2 files changed, 23 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/abayesqr.xml Mon Mar 18 16:07:22 2019 -0400 +++ b/abayesqr.xml Wed Mar 20 13:08:41 2019 -0400 @@ -7,7 +7,8 @@ <command detect_errors="exit_code"><![CDATA[ ln -s '$reference' input.fasta && ln -s '$input' input.sam && - aBayesQR $abayes_params + aBayesQR $abayes_params && + python $__tool_directory__/parse_output.py ]]> </command> <configfiles>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/parse_output.py Wed Mar 20 13:08:41 2019 -0400 @@ -0,0 +1,21 @@ +from Bio.Seq import Seq +from Bio.SeqRecord import SeqRecord +from Bio import SeqIO + +def parse_abayesqr_output(input_text, output_fasta): + with open(input_text) as input_file: + lines = input_file.readlines() + records = [] + for i, line in enumerate(lines): + if i % 2 == 0: + freq = float(line.split()[-1]) + number = int(i/2)+1 + header = 'haplotype-%d_freq-%f' % (number, freq) + if i % 2 == 1: + seq = Seq(line.strip()) + record = SeqRecord(seq, id=header, description='') + records.append(record) + SeqIO.write(records, output_fasta, 'fasta') + +if __name__ == '__main__': + parse_abayesqr_output("test_ViralSeq.txt", "haplotypes.fasta")