Skip to content

Commit

Permalink
Merge pull request galaxyproject#5507 from pimarin/polypolish
Browse files Browse the repository at this point in the history
Fix error with bam input
  • Loading branch information
mvdbeek authored Oct 20, 2023
2 parents 90acc0e + bd0d7f1 commit afc3449
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 22 deletions.
6 changes: 3 additions & 3 deletions tools/polypolish/macro.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

<macros>
<token name="@TOOL_VERSION@">0.5.0</token>
<token name="@VERSION_SUFFIX@">0</token>
<token name="@VERSION_SUFFIX@">1</token>
<token name="@PROFILE@">21.05</token>
<token name="@THREADS@">\${GALAXY_SLOTS:-7}</token>
<xml name="version_command">
Expand Down Expand Up @@ -33,8 +33,8 @@
<option value="non_filter"> No filtering step</option>
</param>
<when value="filter">
<param name="low" argument="--low" type="float" min="0" value="0.1" label="Low percentile threshold" help="Select the lower value to remove [default: 0.1]"/>
<param name="high" argument="--high" type="float" min="0" value="99.9" label="High percentile threshold" help="Select the lower value to remove [default: 99.9]"/>
<param argument="--low" type="float" min="0" value="0.1" label="Low percentile threshold" help="Select the lower value to remove [default: 0.1]"/>
<param argument="--high" type="float" min="0" value="99.9" label="High percentile threshold" help="Select the lower value to remove [default: 99.9]"/>
</when>
<when value="non_filter">
</when>
Expand Down
74 changes: 55 additions & 19 deletions tools/polypolish/polypolish.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,31 @@
For single SAM
======================================*#
#if $input.sam_data_type.sam_selector == 'single'
#if $input.sam_data_type.single_sam.ext == 'unsorted.bam'
#if $input.sam_data_type.single_sam.is_of_type("unsorted.bam")
samtools view -h $input.sam_data_type.single_sam > input_sam &&
#elif $input.sam_data_type.single_sam.ext == 'sam'
ln -s $input.sam_data_type.single_sam input_sam &&
#else
echo "${input.sam_data_type.single_sam} not a sam/bam file"
#end if
polypolish input_data input_sam > '$polished_fasta'
#*======================================
For paired SAM
======================================*#
#elif $input.sam_data_type.sam_selector == 'paired'
#if $input.sam_data_type.R1_sam.ext == 'unsorted.bam'
#if $input.sam_data_type.R1_sam.is_of_type("unsorted.bam")
samtools view -h $input.sam_data_type.R1_sam > sample_R1.sam &&
#elif $input.sam_data_type.R1_sam.ext == 'sam'
ln -s '$input.sam_data_type.R1_sam' sample_R1.sam &&
#else
echo "${input.sam_data_type.single_sam} not a sam/bam file"
#end if
#if $input.sam_data_type.R2_sam.ext == 'unsorted.bam'
#if $input.sam_data_type.R2_sam.is_of_type("unsorted.bam")
samtools view -h $input.sam_data_type.R2_sam > sample_R2.sam &&
#elif $input.sam_data_type.R2_sam.ext == 'sam'
ln -s '$input.sam_data_type.R2_sam' sample_R2.sam &&
#else
echo "${input.sam_data_type.single_sam} not a sam/bam file"
#end if
#if $input.sam_data_type.insert_filter.filter_select == 'filter'
polypolish_insert_filter.py --low '$input.sam_data_type.insert_filter.low'
Expand All @@ -51,10 +57,12 @@
#elif $input.sam_data_type.sam_selector == 'multiple_single'
mkdir single_collection &&
#for $value, $single_sam in enumerate($input.sam_data_type.single_collection):
#if $single_sam.ext == 'unsorted.bam'
#if $single_sam.is_of_type("unsorted.bam")
samtools view -h $single_sam > 'single_collection/$(single_sam.element_identifier).sam' &&
#elif $single_sam.ext == 'sam'
ln -s $single_sam 'single_collection/$(single_sam.element_identifier).$(single_sam.ext)' &&
#else
echo "${single_sam} is not a sam/bam file"
#end if
#end for
polypolish input_data single_collection/*.sam > '$polished_fasta'
Expand All @@ -64,12 +72,12 @@
#elif $input.sam_data_type.sam_selector == "multiple_paired"
mkdir paired_collection &&
#for $value, $paired_sam in enumerate($input.sam_data_type.paired_collection):
#if $paired_sam.forward.ext == 'unsorted.bam'
#if $paired_sam.forward.is_of_type("unsorted.bam")
samtools view -h $paired_sam.forward > 'paired_collection/forward_input$(value)$(paired_sam.forward.element_identifier).sam' &&
#else
ln -s '$paired_sam.forward' 'paired_collection/forward_input$(value)$(paired_sam.forward.element_identifier).sam' &&
#end if
#if $paired_sam.reverse.ext == 'unsorted.bam'
#if $paired_sam.reverse.is_of_type("unsorted.bam")
samtools view -h $paired_sam.reverse > 'paired_collection/reverse_input$(value)$(paired_sam.reverse.element_identifier).sam' &&
#else
ln -s '$paired_sam.reverse' 'paired_collection/reverse_input$(value)$(paired_sam.reverse.element_identifier).sam' &&
Expand Down Expand Up @@ -135,16 +143,16 @@
</conditional>
</section>
<section name="options" title="Options" expanded="False">
<param name="min_depth" argument="--min_depth" type="integer" min="0" value="5" label="Minimal depth"
<param argument="--min_depth" type="integer" min="0" value="5" label="Minimal depth"
help="A base must occur at least this many times in the pileup to be considered valid [default: 5]"/>
<param name="fraction_invalid" argument="--fraction_invalid" type="float" min="0" value="0.2" max="1" label="Minimal invalid fraction"
<param argument="--fraction_invalid" type="float" min="0" value="0.2" max="1" label="Minimal invalid fraction"
help="A base must make up less than this fraction of the read depth to be considered invalid [default: 0.2]"/>
<param name="max_errors" argument="--max_errors" type="integer" min="0" value="10" label="Number of mismatch/indels to ignore alignments"
<param argument="--max_errors" type="integer" min="0" value="10" label="Number of mismatch/indels to ignore alignments"
help="Ignore alignments with more than this many mismatches and indels [default: 10]"/>
<param name="fraction_valid" argument="--fraction_valid" type="float" min="0" value="0.5" max="1" label="Minimal valid fraction"
<param argument="--fraction_valid" type="float" min="0" value="0.5" max="1" label="Minimal valid fraction"
help="A base must make up at least this fraction of the read depth to be considered valid [default: 0.5"/>
<param name="keep_logfile" type="boolean" truevalue="true" falsevalue="false" label="Keep log file"/>
<param name="debug" argument="--debug" type="boolean" truevalue="true" falsevalue="false" label="Keep per base information file"/>
<param argument="--debug" type="boolean" truevalue="true" falsevalue="false" label="Keep per base information file"/>
</section>
</inputs>
<outputs>
Expand Down Expand Up @@ -343,9 +351,9 @@
<param name="sam_selector" value="multiple_single"/>
<param name="single_collection">
<collection type="list">
<element name="R1_sam" value="aligned_test_file/alignement_R1.bam" ftype="unsorted.bam"/>
<element name="R1_bis_sam" value="aligned_test_file/alignement_R1_bis.bam" ftype="unsorted.bam"/>
<element name="R1_ter_sam" value="aligned_test_file/alignement_R1_ter.bam" ftype="unsorted.bam"/>
<element name="R1_sam" value="aligned_test_file/alignement_R1.sam" ftype="sam"/>
<element name="R1_bis_sam" value="aligned_test_file/alignement_R1_bis.sam" ftype="sam"/>
<element name="R1_ter_sam" value="aligned_test_file/alignement_R1_ter.sam" ftype="sam"/>
</collection>
</param>
</conditional>
Expand Down Expand Up @@ -392,6 +400,34 @@
</section>
<output name="polished_fasta" value="polished.fasta"/>
</test>
<!-- Test_12 Test with bam files -->
<test expect_num_outputs="1">
<section name="input">
<param name="fasta_file" value="contigs.fa"/>
<conditional name="sam_data_type">
<param name="sam_selector" value="single"/>
<param name="single_sam" value="aligned_test_file/alignement_R1.bam"/>
</conditional>
</section>
<output name="polished_fasta" value="polished.fasta"/>
</test>
<!-- Test_13 paired bam -->
<test expect_num_outputs="2">
<section name="input">
<param name="fasta_file" value="contigs.fa"/>
<conditional name="sam_data_type">
<param name="sam_selector" value="paired"/>
<param name="R1_sam" value="aligned_test_file/alignement_R1.bam"/>
<param name="R2_sam" value="aligned_test_file/alignement_R2.bam"/>
</conditional>
</section>
<section name="options">
<param name="debug" value="true"/>
<param name="keep_logfile" value="false"/>
</section>
<output name="polished_fasta" value="polished.fasta"/>
<output name="debug_file" value="debug_file_test_2.tsv"/>
</test>
</tests>
<help><![CDATA[
**What it does**
Expand All @@ -401,10 +437,12 @@
**Polypolish pipeline steps**
1. [Optional] Filter aligned reads
- Exclude some alignments based on their insert size
- This should reduce the number of excessive alignments, particularly near the edges of repeat sequences, improving Polypolish's ability to fix errors in those regions.
Exclude some alignments based on their insert size
This should reduce the number of excessive alignments,
particularly near the edges of repeat sequences, improving Polypolish's ability to fix errors in those regions.
2. Clean assembly with filtered reads
**Inputs**
Polypolish need SAM/BAM input format obtain from aligner with option to keep all possible location
Polypolish take on or more assembly as input fasta.
Expand All @@ -414,9 +452,7 @@
For example using bwa mem to align raw data before use, you need :
1. To align each read data independantly (also for paired data)
2. Set the option "Output all alignments for single-ends or unpaired paired-ends" in Select analysis mode>Set input/output options
- This allow multiple ailgnemnt output need to use polypolish
This allow multiple ailgnemnt output need to use polypolish
]]></help>
<expand macro="citations"/>
</tool>

0 comments on commit afc3449

Please sign in to comment.