Skip to content

Commit

Permalink
Merge pull request #24 from cancerit/dev
Browse files Browse the repository at this point in the history
Merge for release
  • Loading branch information
keiranmraine committed Nov 14, 2014
2 parents 1755046 + dbc121f commit 69138b1
Show file tree
Hide file tree
Showing 9 changed files with 82 additions and 25 deletions.
5 changes: 3 additions & 2 deletions perl/MANIFEST
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ docs/pod_html/CN_to_VCF.html
docs/pod_html/failed_cn_csv.html
docs/pod_html/index.html
docs/pod_html/Sanger/CGP/Ascat.html
docs/reports_html/blib-lib-Sanger-CGP-Ascat-pm--subroutine.html
docs/reports_html/blib-lib-Sanger-CGP-Ascat-pm.html
docs/reports_html/common.js
docs/reports_html/cover.css
docs/reports_html/coverage.html
docs/reports_html/css.js
docs/reports_html/digests
docs/reports_html/index.html
docs/reports_html/lib-Sanger-CGP-Ascat-pm--subroutine.html
docs/reports_html/lib-Sanger-CGP-Ascat-pm.html
docs/reports_html/standardista-table-sorting.js
docs/reports_text/coverage.txt
lib/Sanger/CGP/Ascat.pm
Expand All @@ -37,6 +37,7 @@ MANIFEST This list of files
perltidy.LOG
share/ascat/ascat.R
share/ascat/runASCAT.R
share/gender/GRCh37d5_Y.loci
t/1_pm_compile.t
t/2_pl_compile.t
t/CN_to_VCF.t
Expand Down
4 changes: 2 additions & 2 deletions perl/MYMETA.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"unknown"
],
"dynamic_config" : 0,
"generated_by" : "ExtUtils::MakeMaker version 6.68, CPAN::Meta::Converter version 2.131560",
"generated_by" : "ExtUtils::MakeMaker version 6.68, CPAN::Meta::Converter version 2.142690",
"license" : [
"agpl_3"
],
Expand Down Expand Up @@ -37,5 +37,5 @@
}
},
"release_status" : "stable",
"version" : "v1.4.1"
"version" : "v1.5.0"
}
12 changes: 6 additions & 6 deletions perl/MYMETA.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,20 @@ abstract: unknown
author:
- unknown
build_requires:
ExtUtils::MakeMaker: 0
ExtUtils::MakeMaker: '0'
configure_requires:
ExtUtils::MakeMaker: 0
ExtUtils::MakeMaker: '0'
dynamic_config: 0
generated_by: 'ExtUtils::MakeMaker version 6.68, CPAN::Meta::Converter version 2.131560'
generated_by: 'ExtUtils::MakeMaker version 6.68, CPAN::Meta::Converter version 2.142690'
license: open_source
meta-spec:
url: http://module-build.sourceforge.net/META-spec-v1.4.html
version: 1.4
version: '1.4'
name: AscatNgs
no_index:
directory:
- t
- inc
requires:
Const::Fast: 0.014
version: v1.4.1
Const::Fast: '0.014'
version: v1.5.0
23 changes: 11 additions & 12 deletions perl/bin/ascat.pl
Original file line number Diff line number Diff line change
Expand Up @@ -130,16 +130,6 @@ sub setup {
delete $opts{'index'} unless(defined $opts{'index'});
$opts{'minbasequal'} = 20 unless(defined $opts{'minbasequal'});

if(defined $opts{'gender'}){
pod2usage(-message => 'unknown gender value: '.$opts{'gender'}, -verbose => 1) unless(first {$_ eq $opts{'gender'}} @VALID_GENDERS);
if($opts{'gender'} eq 'L') {
$opts{'gender'} = Sanger::CGP::Ascat::Implement::determine_gender(\%opts);
}
} else {
pod2usage(-message => 'gender not set', -verbose => 1);
}


if(exists $opts{'process'}) {
PCAP::Cli::valid_process('process', $opts{'process'}, \@VALID_PROCESS);
if(exists $opts{'index'}) {
Expand All @@ -164,6 +154,15 @@ sub setup {

$opts{'tmp'} = $tmpdir;

if(defined $opts{'gender'}){
pod2usage(-message => 'unknown gender value: '.$opts{'gender'}, -verbose => 1) unless(first {$_ eq $opts{'gender'}} @VALID_GENDERS);
if($opts{'gender'} eq 'L') {
$opts{'gender'} = Sanger::CGP::Ascat::Implement::determine_gender(\%opts);
}
} else {
pod2usage(-message => 'gender not set', -verbose => 1);
}

return \%opts;
}

Expand Down Expand Up @@ -206,8 +205,8 @@ =head1 SYNOPSIS
-minbasequal -q Minimum base quality required before allele is used. [20]
-cpus -c Number of cores to use. [1]
- recommend max 2 during 'input' process.
-locus -l Attempt to determine gender using a male specific locus.
e.g. Y:2654896-2655740 (GRCh37)
-locus -l Using a list of loci, default when '-L' [share/gender/GRCh37d5_Y.loci]
- these are loci that will not present at all in a female sample
-force -f Force completion - solution not possible
- adding this will result in successful completion of analysis even
when ASCAT can't generate a solution. A default copynumber of 5/2
Expand Down
Binary file modified perl/docs.tar.gz
Binary file not shown.
2 changes: 1 addition & 1 deletion perl/lib/Sanger/CGP/Ascat.pm
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ use strict;
use Const::Fast qw(const);
use base 'Exporter';

our $VERSION = '1.4.1';
our $VERSION = '1.5.0';
our @EXPORT = qw($VERSION);

const my $LICENSE =>
Expand Down
55 changes: 54 additions & 1 deletion perl/lib/Sanger/CGP/Ascat/Implement.pm
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ sub _which {
return $path;
}

sub determine_gender {
sub OLD_determine_gender {
my $options = shift;
my $gender = 'XX';
my $samtools = _which('samtools');
Expand All @@ -269,4 +269,57 @@ sub determine_gender {
return $gender;
}

sub determine_gender {
my $options = shift;
my $gender_loci;
if(defined $options->{'locus'}) {
$gender_loci = $options->{'locus'};
}
else {
my $mod_path = dirname(abs_path($0)).'/../share';
$mod_path = module_dir('Sanger::CGP::Ascat::Implement') unless(-e File::Spec->catdir($mod_path, 'gender'));

my $gender_path = File::Spec->catdir($mod_path, 'gender');
$gender_loci = File::Spec->catfile($gender_path,'GRCh37d5_Y.loci');
}

my $command = _which('alleleCounter');
$command .= sprintf $ALLELE_COUNT_PARA, $options->{'tumour'}, File::Spec->catfile($options->{'tmp'}, 'tumour_gender.tsv'), $gender_loci;
$command .= '-m '.$options->{'minbasequal'} if exists $options->{'minbasequal'};
system($command);
my $tum_gender = _parse_gender_results(File::Spec->catfile($options->{'tmp'}, 'tumour_gender.tsv'));
$command = _which('alleleCounter');
$command .= sprintf $ALLELE_COUNT_PARA, $options->{'normal'}, File::Spec->catfile($options->{'tmp'}, 'normal_gender.tsv'), $gender_loci;
$command .= '-m '.$options->{'minbasequal'} if exists $options->{'minbasequal'};
system($command);
my $norm_gender = _parse_gender_results(File::Spec->catfile($options->{'tmp'}, 'normal_gender.tsv'));
if($tum_gender ne $norm_gender) {
die "Gender loci gacve incolclusive results see $options->{tmp}/*_gender.tsv";
}
return $tum_gender;
}

sub _parse_gender_results {
my $file = shift @_;
my $male_loci = 0;
my $total_loci = 0;
open my $fh, '<', $file;
while(my $line = <$fh>) {
next if($line =~ m/^#/);
chomp $line;
#CHR POS Count_A Count_C Count_G Count_T Good_depth
my ($chr, $pos, $a, $c, $g, $t, $depth) = split /\t/, $line;
# all we really care about is the depth
$male_loci++ if($depth > 5);
$total_loci++;
}
close $fh;
my $gender = 'XX';
if($male_loci/$total_loci >= 0.5) {
$gender = 'XY';
}
return $gender;
}


1;
4 changes: 4 additions & 0 deletions perl/share/gender/GRCh37d5_Y.loci
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Y 4546684
Y 2934912
Y 4550107
Y 4549638
2 changes: 1 addition & 1 deletion prerelease.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ echo '### Running perl tests ###'
export HARNESS_PERL_SWITCHES=-MDevel::Cover=-db,reports,-ignore,'t/.*\.t'
rm -rf docs
mkdir -p docs/reports_text
prove --nocolor -I lib t | sed 's/^/ /' # indent output of prove
prove -w --nocolor -I lib t | sed 's/^/ /' # indent output of prove
if [[ $? -ne 0 ]] ; then
echo "\n\tERROR: TESTS FAILED\n"
exit 1
Expand Down

0 comments on commit 69138b1

Please sign in to comment.