Skip to content

Commit

Permalink
Merge pull request #2 from TRON-Bioinformatics/picard2bedtools
Browse files Browse the repository at this point in the history
replace picard by bedtools for the bam2fastq
  • Loading branch information
priesgo committed Mar 25, 2024
2 parents 8a52bb9 + 1206a2d commit 72e1b25
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 3 deletions.
40 changes: 40 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

### Added

### Changed

### Removed


## [0.3.0] - 2024-03-25

### Changed

- Replaced GATKs SamToFastq by bedtools bamtofastq to avoid issue with unmated reads


## [0.2.0] - 2024-03-25

### Added

- Add support for BAM files as input files. It extracts the reads aligned to the MHC region in the canonical
chromosome 6 + all reads from chromosome 6 alt contigs + unmapped reads and converts into FASTQs


## [0.1.0] - 2022-11-02

- First release!


[unreleased]: https://github.com/tron-bioinformatics/tronflow-hla-hd/compare/v0.3.0...HEAD
[0.3.0]: https://github.com/tron-bioinformatics/tronflow-hla-hd/compare/v0.2.0...v0.3.0
[0.2.0]: https://github.com/tron-bioinformatics/tronflow-hla-hd/compare/v0.1.0...v0.2.0
[0.1.0]: https://github.com/tron-bioinformatics/tronflow-hla-hd/releases/tag/v0.1.0
13 changes: 11 additions & 2 deletions modules/00_bam2fastq.nf
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ process BAM2FASTQ {
publishDir "${params.output}/${name}", mode: "copy", pattern: "*.txt"
module params.bowtie2_module

conda (params.enable_conda ? "bioconda::samtools=1.18 bioconda::gatk4=4.2.5.0" : null)
conda (params.enable_conda ? "bioconda::samtools=1.18 bioconda::bedtools=2.31.1" : null)

input:
tuple val(name), val(bam)
Expand All @@ -31,12 +31,21 @@ process BAM2FASTQ {
#Merge bam files
samtools merge -o ${name}.merge.bam ${name}.unmap.bam ${name}.mhc.bam
rm -f ${name}.unmap.bam
rm -f ${name}.mhc.bam
# sort BAM by read name
samtools sort -n ${name}.merge.bam -o ${name}.merge.sorted.bam
rm -f ${name}.merge.bam
#Create fastq
gatk SamToFastq --VALIDATION_STRINGENCY SILENT -I ${name}.merge.bam -F ${name}.hlatmp.1.fastq -F2 ${name}.hlatmp.2.fastq
bedtools bamtofastq -i ${name}.merge.sorted.bam -fq ${name}.hlatmp.1.fastq -fq2 ${name}.hlatmp.2.fastq
#Change fastq ID
cat ${name}.hlatmp.1.fastq |awk '{if(NR%4 == 1){O=\$0;gsub("/1"," 1",O);print O}else{print \$0}}' | gzip > ${name}.hla.1.fastq.gz
cat ${name}.hlatmp.2.fastq |awk '{if(NR%4 == 1){O=\$0;gsub("/2"," 2",O);print O}else{print \$0}}' | gzip > ${name}.hla.2.fastq.gz
rm -f ${name}.hlatmp.1.fastq
rm -f ${name}.hlatmp.2.fastq
"""
}
2 changes: 1 addition & 1 deletion nextflow.config
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ env {
// Capture exit codes from upstream processes when piping
process.shell = ['/bin/bash', '-euo', 'pipefail']

VERSION = '0.2.0'
VERSION = '0.3.0'

manifest {
name = 'TRON-Bioinformatics/tronflow-hlahd'
Expand Down

0 comments on commit 72e1b25

Please sign in to comment.