Skip to content

Commit

Permalink
Merge pull request #27 from ICGC-TCGA-PanCancer/dev
Browse files Browse the repository at this point in the history
Dev - merge 1.0.0 into master ready for release
  • Loading branch information
keiranmraine committed Apr 15, 2014
2 parents b971310 + 217d3ce commit 4bd87bc
Show file tree
Hide file tree
Showing 26 changed files with 351 additions and 65 deletions.
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
/blib
/docs
/pm_to_blib
/MYMETA.yml
/MYMETA.json
/MANIFEST.bak
/install_tmp
/setup.log
5 changes: 5 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
1.0.0
bam_stats.pl actually installed now.
Basic *.bas perl access module.
Upgraded libmaus/biobambam to resolve patch and CentOS install issue.
Reference implementations ensure unique RG:ID between files.
0.3.0
Changes for the re-worked PanCancer submission SOP.
Patch for libmaus issue as not going to be a release in time.
Expand Down
27 changes: 19 additions & 8 deletions INSTALL
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,25 @@ OS:
Other Software
For installation to proceed you require the following packages:

zlib1g-dev
g++
dh-autoreconf
libncurses-dev
pkg-config
libgd2-xpm-dev

This listing is based on Ubuntu 12.04
For Ubuntu (tested with 12.04)
apt-get
zlib1g-dev
g++
dh-autoreconf
libncurses-dev
pkg-config
libgd2-xpm-dev

For CentOS (tested with 6.4)
yum install
zlib-devel
gcc-c++
autoconf
automake
libtool
boost-devel.x86_64
ncurses-devel.x86_64
gd-devel

setup.sh will install
biobambam
Expand Down
5 changes: 4 additions & 1 deletion MANIFEST
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ docs.tar.gz
INSTALL
lib/PCAP.pm
lib/PCAP/Bam.pm
lib/PCAP/Bam/Bas.pm
lib/PCAP/Bam/Stats.pm
lib/PCAP/Bwa.pm
lib/PCAP/Bwa/Meta.pm
Expand All @@ -20,7 +21,6 @@ LICENSE
Makefile.PL
MANIFEST This list of files
MANIFEST.SKIP
patches/fileModeFix.diff
prerelease.sh
README.md
setup.sh
Expand All @@ -31,6 +31,7 @@ t/2_pl_compile.t
t/3_external_progs.t
t/pcap.t
t/pcapBam.t
t/pcapBamBas.t
t/pcapBamStats.t
t/pcapBwa.t
t/pcapBwaMeta.t
Expand All @@ -44,6 +45,7 @@ testData/2_1.fq
testData/3_2.fq
testData/data.file
testData/empty.bam
testData/empty.bam.bas
testData/empty.file
testData/empty.fq
testData/empty_r1_1.fq
Expand All @@ -64,4 +66,5 @@ testData/not_really_a.bam
testData/paired.bam
testData/Stats.bam
testData/Stats.bam.bas
testData/test.bam.bas
testData/unpaired.bam
57 changes: 57 additions & 0 deletions MYMETA.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
{
"abstract" : "unknown",
"author" : [
"unknown"
],
"dynamic_config" : 0,
"generated_by" : "ExtUtils::MakeMaker version 6.68, CPAN::Meta::Converter version 2.131560",
"license" : [
"unknown"
],
"meta-spec" : {
"url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec",
"version" : "2"
},
"name" : "PCAP",
"no_index" : {
"directory" : [
"t",
"inc"
]
},
"prereqs" : {
"build" : {
"requires" : {
"ExtUtils::MakeMaker" : "0"
}
},
"configure" : {
"requires" : {
"ExtUtils::MakeMaker" : "0"
}
},
"runtime" : {
"requires" : {
"Bio::DB::Sam" : "1.39",
"Bio::Root::Version" : "1.006923",
"Capture::Tiny" : "0.24",
"Const::Fast" : "0.014",
"Data::UUID" : "1.219",
"Devel::Cover" : "1.09",
"File::Which" : "0.05",
"GD" : "2.52",
"IPC::System::Simple" : "1.25",
"List::Util" : "1.38",
"Math::Gradient" : "0.04",
"Module::Build" : "0.42",
"Pod::Coverage" : "0.23",
"Proc::ProcessTable" : "0.5",
"Term::UI" : "0.42",
"Test::Fatal" : "0.013",
"Try::Tiny" : "0.19"
}
}
},
"release_status" : "stable",
"version" : "v1.0.0"
}
38 changes: 38 additions & 0 deletions MYMETA.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
abstract: unknown
author:
- unknown
build_requires:
ExtUtils::MakeMaker: 0
configure_requires:
ExtUtils::MakeMaker: 0
dynamic_config: 0
generated_by: 'ExtUtils::MakeMaker version 6.68, CPAN::Meta::Converter version 2.131560'
license: unknown
meta-spec:
url: http://module-build.sourceforge.net/META-spec-v1.4.html
version: 1.4
name: PCAP
no_index:
directory:
- t
- inc
requires:
Bio::DB::Sam: 1.39
Bio::Root::Version: 1.006923
Capture::Tiny: 0.24
Const::Fast: 0.014
Data::UUID: 1.219
Devel::Cover: 1.09
File::Which: 0.05
GD: 2.52
IPC::System::Simple: 1.25
List::Util: 1.38
Math::Gradient: 0.04
Module::Build: 0.42
Pod::Coverage: 0.23
Proc::ProcessTable: 0.5
Term::UI: 0.42
Test::Fatal: 0.013
Try::Tiny: 0.19
version: v1.0.0
1 change: 1 addition & 0 deletions Makefile.PL
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ WriteMakefile(
EXE_FILES => [qw( bin/bam_to_sra_sub.pl
bin/bwa_aln.pl
bin/bwa_mem.pl
bin/bam_stats.pl
bin/diff_bams.pl
bin/monitor.pl)],
PREREQ_PM => {
Expand Down
3 changes: 0 additions & 3 deletions bin/bwa_aln.pl
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,6 @@ BEGIN
use PCAP::Bwa;
use PCAP::Bwa::Meta;

my @mod_list = keys %INC;
exit 0 if(first {$_ =~ m|^Devel/Cover| } @mod_list);

const my @VALID_PROCESS => qw(bam2fq aln sampe mark);
const my %INDEX_FACTOR => ( 'bam2fq' => 1,
'aln' => 2,
Expand Down
3 changes: 0 additions & 3 deletions bin/bwa_mem.pl
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,6 @@ BEGIN
use PCAP::Bwa::Meta;
use version;

my @mod_list = keys %INC;
exit 0 if(first {$_ =~ m|^Devel/Cover| } @mod_list);

const my @VALID_PROCESS => qw(bwamem mark);
const my %INDEX_FACTOR => ( 'bwamem' => 1,
'mark' => 1,);
Expand Down
Binary file modified docs.tar.gz
Binary file not shown.
14 changes: 8 additions & 6 deletions lib/PCAP.pm
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ package PCAP;
use strict;
use Const::Fast qw(const);

our $VERSION = '0.3.0';
our $VERSION = '1.0.0';

const my $LICENSE =>
"#################
Expand All @@ -33,11 +33,13 @@ const my $LICENSE =>
#################";

const my $DEFAULT_PATH => 'biobambam,samtools,bwa';
const my %UPGRADE_PATH => ( '0.1.0' => 'biobambam,samtools,bwa',
'0.1.1' => 'biobambam,bwa',
'0.1.2' => 'biobambam',
'0.2.0' => 'biobambam',
'0.3.0' => '',
const my %UPGRADE_PATH => ( '0.1.0' => 'biobambam,samtools,bwa',
'0.1.1' => 'biobambam,bwa',
'0.1.2' => 'biobambam',
'0.2.0' => 'biobambam',
'0.2.99' => 'biobambam',
'0.3.0' => 'biobambam',
'1.0.0' => '',
);

sub license {
Expand Down
9 changes: 8 additions & 1 deletion lib/PCAP/Bam.pm
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ use File::Which qw(which);
use Bio::DB::Sam;
use Carp qw(croak);
use List::Util qw(first);
use Data::UUID;

use PCAP::Threaded;

Expand All @@ -51,14 +52,18 @@ sub new {
}

sub rg_line_for_output {
my $bam = shift;
my ($bam, $uniq_id) = @_;
my $sam = sam_ob($bam);
my $header = $sam->header->text;
my $rg_line;
while($header =~ m/^(\@RG\t[^\n]+)/xmsg) {
my $new_rg = $1;
die "BAM file appears to contain data for multiple readgroups, not supported: \n\n$header\n" if(defined $rg_line);
$rg_line = $new_rg;
if($uniq_id) {
my $uuid = lc Data::UUID->new->create_str;
$rg_line =~ s/\tID:[^\t]+/\tID:$uuid/;
}
$rg_line =~ s/\t/\\t/g;
}
return ($rg_line, $sam); # also return the SAM object
Expand Down Expand Up @@ -359,6 +364,8 @@ The SAM object is also returned should it be useful for other calls
Takes BAM or Bio::DB::Sam object as input and returns the string representation for the RG line.
Intended for use when adding RG to BWA MEM output and is only useful in single RG BAMs
Optional second boolean arg causes ID to be replaced with a UUID.
The SAM object is also returned should it be useful for other calls
=item sam_ob
Expand Down
119 changes: 119 additions & 0 deletions lib/PCAP/Bam/Bas.pm
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
package PCAP::Bam::Bas;

##########LICENCE##########
# PCAP - NGS reference implementations and helper code for the ICGC/TCGA Pan-Cancer Analysis Project
# Copyright (C) 2014 ICGC PanCancer Project
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not see:
# http://www.gnu.org/licenses/gpl-2.0.html
##########LICENCE##########

use PCAP;
our $VERSION = PCAP->VERSION;

use strict;
use English qw( -no_match_vars );
use warnings FATAL=>'all';
use autodie qw( :all );
use Carp qw(croak carp);

sub new {
my ($class, $bas) = @_;
my $self = { };
bless $self, $class;
$self->_init($bas);
return $self;
}

sub _init {
my ($self, $bas) = @_;
croak "No bas file defined" if(!defined $bas);
die "*.bas file: $bas does not exist" unless(-e $bas);
die "*.bas file: $bas is empty" unless(-s $bas);
open my $IN, '<', $bas;
$self->bas_keys($IN);
$self->_import_data($IN);
close $IN;
return 1;
}

sub _import_data {
my ($self, $fh) = @_;
while(my $line = <$fh>) {
chomp $line;
my @bits = split /\t/, $line;
my %rg;
for my $key(@{$self->bas_keys}) {
$rg{$key} = $bits[$self->{'key_pos_map'}->{$key}];
}
$self->{'_data'}->{$rg{'readgroup'}} = \%rg;
}
return 1;
}

sub bas_keys {
my ($self, $key_fh) = @_;
croak "bas_keys should only be initialised once\n" if(exists $self->{'keys'} && defined $key_fh);
if(defined $key_fh) {
my $line = <$key_fh>;
chomp $line;
my @head = split /\t/, $line;
my %key_pos_map;
my $pos=0;
for my $key(@head) {
$key_pos_map{$key} = $pos++;
}
$self->{'keys'} = \@head;
$self->{'key_pos_map'} = \%key_pos_map;
}
return $self->{'keys'};
}

sub get {
my ($self, $rg, $key) = @_;
die qq{Readgroup '$rg' does not exist\n} unless(exists $self->{'_data'}->{$rg});
return exists $self->{'_data'}->{$rg}->{$key} ? $self->{'_data'}->{$rg}->{$key} : undef;
}

1;

__END__
=head1 PCAP::Bam::Bas
Convenience class for accessing data in a *.bas file.
=head2 METHODS
=over 2
=item new
Construct an access object for BAM statistics file.
my $bas_ob = PCAP::Bam::Bas->new($bas);
=item bas_keys
Returns the list of available keys for this BAS file.
=item get
Retrieve a value by its readgroup and key:
$bas->($rg, 'median_insert_size');
NOTE: Returns undef if a key is not available.
=back
Loading

0 comments on commit 4bd87bc

Please sign in to comment.