Skip to content

Commit

Permalink
Update modules/local/samtools_replaceheader.nf
Browse files Browse the repository at this point in the history
Co-authored-by: Matthieu Muffato <[email protected]>
  • Loading branch information
tkchafin and muffato authored Jul 11, 2024
1 parent f5b3edc commit a7c125b
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions modules/local/samtools_replaceheader.nf
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,18 @@ process SAMTOOLS_REHEADER {
"""
# Replace SQ lines with those from external template
( samtools view --no-PG --header-only ${file} | \\
grep -v ^@SQ && grep ^@SQ ${header} ) > .temp.header.sam
grep -v ^@SQ && grep ^@SQ ${header} ) > temp.header.sam
# custom sort for readability (retain order of insertion but sort groups by tag)
( grep ^@HD .temp.header.sam || true && \
grep ^@SQ .temp.header.sam || true && \
grep ^@RG .temp.header.sam || true && \
grep ^@PG .temp.header.sam || true && \
grep -v -E '^@HD|^@SQ|^@RG|^@PG' .temp.header.sam || true; \
) > .temp.sorted.header.sam
( grep ^@HD temp.header.sam || true && \
grep ^@SQ temp.header.sam || true && \
grep ^@RG temp.header.sam || true && \
grep ^@PG temp.header.sam || true && \
grep -v -E '^@HD|^@SQ|^@RG|^@PG' temp.header.sam || true; \
) > temp.sorted.header.sam
# Insert new header into file
samtools reheader .temp.sorted.header.sam ${file} > ${prefix}.${suffix}
samtools reheader temp.sorted.header.sam ${file} > ${prefix}.${suffix}
cat <<-END_VERSIONS > versions.yml
"${task.process}":
Expand Down

0 comments on commit a7c125b

Please sign in to comment.