-
Notifications
You must be signed in to change notification settings - Fork 14
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 #27 from ICGC-TCGA-PanCancer/dev
Dev - merge 1.0.0 into master ready for release
- Loading branch information
Showing
26 changed files
with
351 additions
and
65 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,8 +2,6 @@ | |
/blib | ||
/docs | ||
/pm_to_blib | ||
/MYMETA.yml | ||
/MYMETA.json | ||
/MANIFEST.bak | ||
/install_tmp | ||
/setup.log |
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,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" | ||
} |
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,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 |
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
Binary file not shown.
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,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 |
Oops, something went wrong.