From f235486d1558360efc085d9e9d4f16b660782d94 Mon Sep 17 00:00:00 2001 From: mmterpstra Date: Wed, 19 Jul 2017 12:05:35 +0200 Subject: [PATCH] fixes to NugeneDigitalsplitter.pl --- ...roups-0.1.9-foss-2016a-Perl-5.20.2-bare.eb | 36 +++++++++++++++++++ src/NugeneDigitalSplitter.pl | 11 ++++-- 2 files changed, 44 insertions(+), 3 deletions(-) create mode 100644 eb/DigitalBarcodeReadgroups-0.1.9-foss-2016a-Perl-5.20.2-bare.eb diff --git a/eb/DigitalBarcodeReadgroups-0.1.9-foss-2016a-Perl-5.20.2-bare.eb b/eb/DigitalBarcodeReadgroups-0.1.9-foss-2016a-Perl-5.20.2-bare.eb new file mode 100644 index 0000000..4159eaf --- /dev/null +++ b/eb/DigitalBarcodeReadgroups-0.1.9-foss-2016a-Perl-5.20.2-bare.eb @@ -0,0 +1,36 @@ +easyblock = 'Tarball' + +name = 'DigitalBarcodeReadgroups' +version = '0.1.9' + +homepage = 'https://github.com/mmterpstra/%s' % (name) +description = """Misc tools""" + +toolchain = {'name': 'foss', 'version': '2016a'} + +source_urls = [('https://github.com/mmterpstra/%s/archive/' % (name) )] +sources = [ '%s.tar.gz' % version ] + +perl = 'Perl' +perlver = '5.20.2' +perlversuffix = '-bare' +versionsuffix = '-%s-%s%s' % (perl, perlver, perlversuffix) + +samtools='SAMtools' +samtoolsver='1.3' + +dependencies = [ + (perl, perlver, perlversuffix), + (samtools, samtoolsver), +] + +# +# Check if all binaries are present. +# + +sanity_check_paths = { + 'files': [ 'src/NugeneDigitalSplitter.pl', 'src/NugeneMergeFastqFiles.pl' ], + 'dirs': [ 'src/' ], +} + +moduleclass = 'bio' diff --git a/src/NugeneDigitalSplitter.pl b/src/NugeneDigitalSplitter.pl index c0ea80a..4199ee6 100644 --- a/src/NugeneDigitalSplitter.pl +++ b/src/NugeneDigitalSplitter.pl @@ -96,6 +96,7 @@ sub VERSION_MESSAGE { } sub validateSamTag { + my $tag = shift @_; die "## ".localtime(time())." ## ERROR invalid tag does not match /[A-Za-z][A-Za-z0-9]/" if(not($tag =~ m/[A-Za-z][A-Za-z0-9]/)); } @@ -109,7 +110,7 @@ sub ApplyPicardTag { my $cmdin = "samtools view -h $bam"; open(my $in,'-|',$cmdin) or die "## ".localtime(time())." ## ERROR invalid read from command $cmdin"; - my $cmdout = "samtools view -S -b - > $bamout"; + my $cmdout = "samtools view -h -S -b > $bamout"; #my $cmdout = "cat - > $bamout"; open(my $out,'|-',$cmdout) or die "## ".localtime(time())." ## ERROR invalid write to command $cmdout"; @@ -126,7 +127,7 @@ sub ApplyPicardTag { my $randombc = SamGetRandombc($sam); $randombc = substr($randombc,0,$opts -> {'l'}) if(defined($opts -> {'l'}) && $opts -> {'l'} > 0); $sam = SamRemoveRandombc($sam); - + $line = SamAsString($sam); #a $line .= "\t$tag:Z:$randombc"; #die "$line"; @@ -137,6 +138,10 @@ sub ApplyPicardTag { warn "## ".localtime(time())." ## DONE\n" } +sub SamAsString { + my $sam = shift @_; + return join("\t", @{$sam}); +} sub CollectNugeneRgData { my $bam = shift @_; @@ -265,7 +270,7 @@ sub SamRemoveRandombc { $readname[2] =~ s/[ATCGN]+$//g; #my $randombc=$1; #die "No randombc present in sam record! Dump of sam record:".Dumper($sam) if(not(defined($randombc))); - $sam->[0]=join("\t",@readname); + $sam->[0]=join(':',@readname); return $sam; }