Skip to content

Commit

Permalink
fixes to NugeneDigitalsplitter.pl
Browse files Browse the repository at this point in the history
  • Loading branch information
mmterpstra committed Jul 19, 2017
1 parent 0ac10cd commit f235486
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 3 deletions.
36 changes: 36 additions & 0 deletions eb/DigitalBarcodeReadgroups-0.1.9-foss-2016a-Perl-5.20.2-bare.eb
Original file line number Diff line number Diff line change
@@ -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'
11 changes: 8 additions & 3 deletions src/NugeneDigitalSplitter.pl
Original file line number Diff line number Diff line change
Expand Up @@ -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]/));
}

Expand All @@ -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";

Expand All @@ -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";
Expand All @@ -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 @_;

Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit f235486

Please sign in to comment.