-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #44 from sanger-tol/hic_minimap2
add hic minimap2
- Loading branch information
Showing
23 changed files
with
617 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#remove the read number added earlier --yy5 | ||
awk 'BEGIN{OFS="\t"}{if($1 ~ /^@/) {print} else {$2=and($2,compl(2048)); print substr($1,2),$2,$3,$4,$5,$6,$7,$8,$9,$10,$11}}' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
#!/usr/bin/perl | ||
use strict; | ||
use warnings; | ||
|
||
my $prev_id = ""; | ||
my @five; | ||
my @three; | ||
my @unmap; | ||
my @mid; | ||
my @all; | ||
my $counter = 0; | ||
|
||
while (<STDIN>){ | ||
chomp; | ||
if (/^@/){ | ||
print $_."\n"; | ||
next; | ||
} | ||
my ($id, $flag, $chr_from, $loc_from, $mapq, $cigar, $d1, $d2, $d3, $read, $read_qual, @rest) = split /\t/; | ||
my $bin = reverse(dec2bin($flag)); | ||
my @binary = split(//,$bin); | ||
if ($prev_id ne $id && $prev_id ne ""){ | ||
if ($counter == 1){ | ||
if (@five == 1){ | ||
print $five[0]."\n"; | ||
} | ||
else{ | ||
my ($id_1, $flag_1, $chr_from_1, $loc_from_1, $mapq_1, $cigar_1, $d1_1, $d2_1, $d3_1, $read_1, $read_qual_1, @rest_1) = split /\t/, $all[0]; | ||
my $bin_1 = reverse(dec2bin($flag_1)); | ||
my @binary_1 = split(//,$bin_1); | ||
$binary_1[2] = 1; | ||
my $bin_1_new = reverse(join("",@binary_1)); | ||
my $flag_1_new = bin2dec($bin_1_new); | ||
print(join("\t",$id_1, $flag_1_new, $chr_from_1, $loc_from_1, $mapq_1, $cigar_1, $d1_1, $d2_1, $d3_1, $read_1, $read_qual_1, @rest_1)."\n"); | ||
} | ||
} | ||
elsif ($counter == 2 && @five == 1){ | ||
print $five[0]."\n"; | ||
} | ||
else{ | ||
my ($id_1, $flag_1, $chr_from_1, $loc_from_1, $mapq_1, $cigar_1, $d1_1, $d2_1, $d3_1, $read_1, $read_qual_1, @rest_1) = split /\t/, $all[0]; | ||
my $bin_1 = reverse(dec2bin($flag_1)); | ||
my @binary_1 = split(//,$bin_1); | ||
$binary_1[2] = 1; | ||
my $bin_1_new = reverse(join("",@binary_1)); | ||
my $flag_1_new = bin2dec($bin_1_new); | ||
print(join("\t",$id_1, $flag_1_new, $chr_from_1, $loc_from_1, $mapq_1, $cigar_1, $d1_1, $d2_1, $d3_1, $read_1, $read_qual_1, @rest_1)."\n"); | ||
} | ||
|
||
$counter = 0; | ||
undef @unmap; | ||
undef @five; | ||
undef @three; | ||
undef @mid; | ||
undef @all; | ||
} | ||
|
||
$counter++; | ||
$prev_id = $id; | ||
push @all,$_; | ||
if ($binary[2]==1){ | ||
push @unmap,$_; | ||
} | ||
elsif ($binary[4]==0 && $cigar =~ m/^[0-9]*M/ || $binary[4]==1 && $cigar =~ m/.*M$/){ | ||
push @five, $_; | ||
} | ||
elsif ($binary[4]==1 && $cigar =~ m/^[0-9]*M/ || $binary[4]==0 && $cigar =~ m/.*M$/){ | ||
push @three, $_; | ||
} | ||
elsif ($cigar =~ m/^[0-9]*[HS].*M.*[HS]$/){ | ||
push @mid, $_; | ||
} | ||
} | ||
|
||
if ($counter == 1){ | ||
if (@five == 1){ | ||
print $five[0]."\n"; | ||
} | ||
else{ | ||
my ($id_1, $flag_1, $chr_from_1, $loc_from_1, $mapq_1, $cigar_1, $d1_1, $d2_1, $d3_1, $read_1, $read_qual_1, @rest_1) = split /\t/, $all[0]; | ||
my $bin_1 = reverse(dec2bin($flag_1)); | ||
my @binary_1 = split(//,$bin_1); | ||
$binary_1[2] = 1; | ||
my $bin_1_new = reverse(join("",@binary_1)); | ||
my $flag_1_new = bin2dec($bin_1_new); | ||
print(join("\t",$id_1, $flag_1_new, $chr_from_1, $loc_from_1, $mapq_1, $cigar_1, $d1_1, $d2_1, $d3_1, $read_1, $read_qual_1, @rest_1)."\n"); | ||
} | ||
} | ||
elsif ($counter == 2 && @five == 1){ | ||
print $five[0]."\n"; | ||
} | ||
else{ | ||
my ($id_1, $flag_1, $chr_from_1, $loc_from_1, $mapq_1, $cigar_1, $d1_1, $d2_1, $d3_1, $read_1, $read_qual_1, @rest_1) = split /\t/, $all[0]; | ||
my $bin_1 = reverse(dec2bin($flag_1)); | ||
my @binary_1 = split(//,$bin_1); | ||
$binary_1[2] = 1; | ||
my $bin_1_new = reverse(join("",@binary_1)); | ||
my $flag_1_new = bin2dec($bin_1_new); | ||
print(join("\t",$id_1, $flag_1_new, $chr_from_1, $loc_from_1, $mapq_1, $cigar_1, $d1_1, $d2_1, $d3_1, $read_1, $read_qual_1, @rest_1)."\n"); | ||
} | ||
|
||
sub dec2bin { | ||
my $str = unpack("B32", pack("N", shift)); | ||
return $str; | ||
} | ||
|
||
sub bin2dec { | ||
return unpack("N", pack("B32", substr("0" x 32 . shift, -32))); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#!/bin/bash | ||
|
||
# grep_pg.sh | ||
# ------------------- | ||
# A shell script to exclude pg lines and label read 1 and read 2 from cram containers | ||
# | ||
# ------------------- | ||
# Author = yy5 | ||
|
||
grep -v "^@PG" | awk '{if($1 ~ /^@/) {print($0)} else {if(and($2,64)>0) {print("1"$0)} else {print("2"$0)}}}' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
modules/local/cram_filter_minimap2_filter5end_fixmate_sort.nf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
process CRAM_FILTER_MINIMAP2_FILTER5END_FIXMATE_SORT { | ||
tag "$meta.id" | ||
label "process_high" | ||
|
||
container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ? | ||
'https://depot.galaxyproject.org/singularity/mulled-v2-1a6fe65bd6674daba65066aa796ed8f5e8b4687b:688e175eb0db54de17822ba7810cc9e20fa06dd5-0' : | ||
'biocontainers/mulled-v2-1a6fe65bd6674daba65066aa796ed8f5e8b4687b:688e175eb0db54de17822ba7810cc9e20fa06dd5-0' }" | ||
|
||
input: | ||
tuple val(meta), path(cramfile), path(cramindex), val(from), val(to), val(base), val(chunkid), val(rglines), val(ref), path(reference) | ||
|
||
output: | ||
tuple val(meta), path("*.bam"), emit: mappedbam | ||
path "versions.yml" , emit: versions | ||
|
||
when: | ||
task.ext.when == null || task.ext.when | ||
|
||
script: | ||
def args = task.ext.args ?: '' | ||
def args1 = task.ext.args1 ?: '' | ||
def args2 = task.ext.args2 ?: '' | ||
def args3 = task.ext.args3 ?: '' | ||
def args4 = task.ext.args4 ?: '' | ||
def prefix = task.ext.prefix ?: "${meta.id}" | ||
def VERSION = "1.15" // Staden_io versions break the pipeline | ||
""" | ||
cram_filter -n ${from}-${to} ${cramfile} - | \\ | ||
samtools fastq ${args1} - | \\ | ||
minimap2 -t${task.cpus} -R '${rglines}' ${args2} ${ref} - | \\ | ||
${projectDir}/bin/grep_pg.sh | \\ | ||
perl ${projectDir}/bin/filter_five_end.pl | \\ | ||
${projectDir}/bin/awk_filter_reads.sh | \\ | ||
samtools fixmate ${args3} - - | \\ | ||
samtools sort ${args4} -@${task.cpus} -T ${base}_${chunkid}_sort_tmp -o ${prefix}_${base}_${chunkid}_mm.bam - | ||
cat <<-END_VERSIONS > versions.yml | ||
"${task.process}": | ||
samtools: \$(echo \$(samtools --version 2>&1) | sed 's/^.*samtools //; s/Using.*\$//' ) | ||
minimap2: \$(minimap2 --version | sed 's/minimap2 //g') | ||
staden_io: $VERSION | ||
END_VERSIONS | ||
""" | ||
|
||
stub: | ||
def prefix = task.ext.prefix ?: "${meta.id}" | ||
def base = "45022_3#2" | ||
def chunkid = "1" | ||
""" | ||
touch ${prefix}_${base}_${chunkid}_mm.bam | ||
cat <<-END_VERSIONS > versions.yml | ||
"${task.process}": | ||
samtools: \$(echo \$(samtools --version 2>&1) | sed 's/^.*samtools //; s/Using.*\$//' ) | ||
minimap2: \$(echo \$(minimap2 version 2>&1) | sed 's/.* //') | ||
staden_io: $VERSION | ||
END_VERSIONS | ||
""" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.