Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use CRAM reference in samtools commands #236

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions modules/local/common.nf
Original file line number Diff line number Diff line change
Expand Up @@ -722,6 +722,7 @@ process extract_not_haplotagged_contigs {
cpus 8
memory 8.GB
input:
tuple path(ref), path(ref_idx), path(ref_cache), env(REF_PATH)
tuple path(xam), path(xam_idx), val(xam_meta)
path("haplotagged_sq.fosn")
output:
Expand All @@ -732,7 +733,7 @@ process extract_not_haplotagged_contigs {
mkdir -p output

# create file of sequence names by extracting all SQ SN
samtools view -H --no-PG '${xam}' | grep '^@SQ' | sed -nE 's,.*SN:([^[:space:]]*).*,\\1,p' > all_sq.fosn
samtools view -r '${ref}' -H --no-PG '${xam}' | grep '^@SQ' | sed -nE 's,.*SN:([^[:space:]]*).*,\\1,p' > all_sq.fosn

# pull out contigs that do not appear in the haplotagged fofn
# sort haplotagged contig list here (dont leave it to nextflow collectfile)
Expand All @@ -741,14 +742,14 @@ process extract_not_haplotagged_contigs {
if [ -s unhaplotagged_sq.fosn ]; then
while read sq; do
echo "Extracting \${sq}"
samtools view ${xam} "\${sq}" -@ ${extra_view_threads} --no-PG -o "output/\${sq}_nohp.bam"
samtools view -r '${ref}' ${xam} "\${sq}" -@ ${extra_view_threads} --no-PG -o "output/\${sq}_nohp.bam"
done < unhaplotagged_sq.fosn
fi

# bonus bam: pull out unaligned - this file will always be created
# use '*' region rather than -f4 for speeds
echo "Extracting *"
samtools view ${xam} '*' -@ ${extra_view_threads} --no-PG -o output/unaligned.bam
samtools view -r '${ref}' ${xam} '*' -@ ${extra_view_threads} --no-PG -o output/unaligned.bam
"""
}

2 changes: 1 addition & 1 deletion workflows/wf-human-snp.nf
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ workflow snp {
// chr, extracting all the decoys and unaligned reads is reasonably
// inexpensive. a small BED with high coverage may be less appropriate.
nothaplotagged_ctg_bams = \
extract_not_haplotagged_contigs(bam_channel, haplotagged_fosn)
extract_not_haplotagged_contigs(ref, bam_channel, haplotagged_fosn)
| transpose // squish to meet the expected shape for haplotagged_ctg_bams

xams_to_cat = \
Expand Down