Skip to content

Commit

Permalink
recursively map
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark Fiers committed Jun 11, 2012
1 parent 58ea57d commit e444ca1
Show file tree
Hide file tree
Showing 2 changed files with 114 additions and 0 deletions.
56 changes: 56 additions & 0 deletions template2/recursive_map.jinja2
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
### run

reference={{reference}}

{% for i in range(iterations) %}
{% if i <= (iterations / 2) %}{% set aln_param=param_strict %}
{% else %}{% set aln_param=param_loose %}
{% endif %}
echo "Iteration {{i}} ---"
echo "With reference: ${reference}"
if [[ ! -f "db.{{i}}.ann" ]]
then
echo "create bwa database {{i}}"
bwa index -p db.{{i}} ${reference}
fi

echo "start aligning $i"
bamfiles=""
{% for ffq in fq_forward %}
{% set rfq = fq_reverse[loop.index0] %}
base=`basename {{ ffq }} .fq`
[[ -f "${base}__{{i}}.f.sai" ]] || \
bwa aln {{ aln_param }} -t {{ threads }} \
-f ${base}__{{i}}.f.sai db.{{i}} {{ ffq }}
[[ -f "${base}__{{i}}.r.sai" ]] || \
bwa aln {{ aln_param }} -t {{ threads }} \
-f ${base}__{{i}}.r.sai db.{{i}} {{ rfq }}
[[ -f ${base}__{{i}}.bam ]] || \
bwa sampe db.{{i}} ${base}__{{i}}.f.sai ${base}__{{i}}.r.sai \
{{ ffq }} {{ rfq }} \
| samtools view -Sb -f 2 - \
| samtools sort - ${base}__{{i}}
bamfiles="${bamfiles} ${base}__{{i}}.bam"
{% endfor %}

echo "bamfiles collected: ${bamfiles}"
if [[ ! -f variants.{{i}}.vcf ]]
then
samtools mpileup -uf $reference \
${bamfiles} \
| bcftools view -bvcg - \
> variants.raw.{{i}}.bcf
bcftools view variants.raw.{{i}}.bcf \
| vcfutils.pl varFilter -D100 \
> variants.{{i}}.vcf
fi

if [[ ! -f consensus.{{i}}.fasta ]]
then
vcf_applicator ${reference} variants.{{i}}.vcf \
consensus.{{i}}.fasta
fi

reference=consensus.{{i}}.fasta
#false
{% endfor %}
58 changes: 58 additions & 0 deletions template2/recursive_map.moa
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
author: Mark Fiers
backend: ruff
commands:
run:
help: 'recusive map'
mode: reduce
creation_date: Fri, 08 Jun 2012 13:32:30 +1200
title: Recursively map a genome to the reference
description: Recursively map a resequence dataset against a reference genome
modification_date: Fri, 08 Jun 2012 13:43:19 +1200
moa_id: recursive_map
name: recursive_map
filesets:
reference:
category: prerequisite
type: single
optional: false
pattern: '*/*'
fq_forward:
category: input
help: fastq input files directory - forward
optional: false
pattern: '*/*_1.fq'
type: set
fq_reverse:
category: input
help: fastq input files directory - reverse
optional: true
pattern: '*/*_2.fq'
source: fq_forward
type: map
output:
category: output
help: 'base output filename'
optional: true
pattern: output
type: single
parameters:
iterations:
help: 'no of iterations to run'
optional: true
type: integer
default: 3
threads:
help: 'Number of threads to use'
optional: true
type: integer
default: 4
param_strict:
help: 'Strict parameters for the first half of alignment runs'
optional: true
type: string
default: ''
param_loose:
help: 'Looser parameters for the second half of alignment runs'
optional: true
type: string
default: '-e 1 -E 3 -k 3 -O 10'

0 comments on commit e444ca1

Please sign in to comment.