Skip to content

Commit

Permalink
Merge pull request #116 from icgc-argo/bam-merge-sort-markdup.0.1.11.0
Browse files Browse the repository at this point in the history
Bam merge sort markdup.0.1.11.0
  • Loading branch information
lindaxiang authored Nov 10, 2020
2 parents 3bcce13 + f792826 commit a3d1200
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 13 deletions.
2 changes: 1 addition & 1 deletion tools/bam-merge-sort-markdup/bam-merge-sort-markdup.nf
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
*/

nextflow.enable.dsl=2
version = '0.1.10.0'
version = '0.1.11.0'

params.aligned_lane_bams = ""
params.ref_genome_gz = ""
Expand Down
17 changes: 5 additions & 12 deletions tools/bam-merge-sort-markdup/bam-merge-sort-markdup.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def main():
parser.add_argument("-n", "--cpus", dest='cpus', type=int, default=cpu_count())
parser.add_argument("-d", "--mdup", dest='mdup', action='store_true')
parser.add_argument("-l", "--lossy", dest='lossy', action='store_true')
parser.add_argument("-o", "--output-format", dest='output_format', choices=['bam', 'cram'], default=['cram'], nargs='+')
parser.add_argument("-o", "--output-format", dest='output_format', default='cram', choices=['bam', 'cram'])

args = parser.parse_args()

Expand All @@ -66,21 +66,14 @@ def main():
else:
cram = 'samtools view -C -T %s -@ %s --write-index /dev/stdin -o %s ' % (args.reference, args.cpus, args.output_base + ".cram")

tee = 'tee %s ' % (args.output_base + ".bam")
bai = 'samtools index -@ %s /dev/stdin %s' % (args.cpus, args.output_base + ".bam.bai")
bai1 = 'samtools index -@ %s %s %s ' % (args.cpus, args.output_base + ".bam", args.output_base + ".bam.bai")
bam = 'samtools view -b -h -@ %s --write-index /dev/stdin -o %s##idx##%s ' % (args.cpus, args.output_base + ".bam", args.output_base + ".bam.bai")
crai1 = 'samtools index -@ %s %s %s ' % (args.cpus, args.output_base + ".cram", args.output_base + ".cram.crai")

# build command
if "bam" in args.output_format and "cram" in args.output_format:
cmd.append('|'.join([merge, tee, cram]))
cmd.append(bai1)
if args.lossy: cmd.append(crai1)

elif "bam" in args.output_format and not "cram" in args.output_format:
cmd.append('|'.join([merge, tee, bai]))
if args.output_format == 'bam':
cmd.append('|'.join([merge, bam]))

elif not "bam" in args.output_format and "cram" in args.output_format:
elif args.output_format == 'cram':
cmd.append('|'.join([merge, cram]))
if args.lossy: cmd.append(crai1)
else:
Expand Down
13 changes: 13 additions & 0 deletions tools/bam-merge-sort-markdup/tests/test-job2.nf.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"aligned_lane_bams": [
"input/grch38-aligned.D0RH0_2.lane.bam",
"input/grch38-aligned.D0RE2_1.lane.bam",
"input/grch38-aligned.C0HVY_2.lane.bam"
],
"ref_genome_gz": "reference/tiny-grch38-chr11-530001-537000.fa.gz",
"tempdir": "/tmp",
"markdup": false,
"output_format": "bam",
"cpus": 1,
"mem": 2
}
12 changes: 12 additions & 0 deletions tools/bam-merge-sort-markdup/tests/test-job3.nf.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"aligned_lane_bams": [
"input/grch38-aligned.D0RH0_2.lane.bam",
"input/grch38-aligned.D0RE2_1.lane.bam",
"input/grch38-aligned.C0HVY_2.lane.bam"
],
"ref_genome_gz": "reference/tiny-grch38-chr11-530001-537000.fa.gz",
"tempdir": "/tmp",
"output_format": "bam",
"cpus": 1,
"mem": 2
}

0 comments on commit a3d1200

Please sign in to comment.