Skip to content

Commit

Permalink
Merge branch 'hotfix/v3.0.3'
Browse files Browse the repository at this point in the history
  • Loading branch information
keiranmraine committed Jul 6, 2016
2 parents e28c87d + 5aa58bc commit 2324d94
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 6 deletions.
1 change: 1 addition & 0 deletions perl/MANIFEST
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ MANIFEST This list of files
share/ascat/runASCAT.R
share/gender/GRCh37d5_Y.loci
share/images/NoSolution.png
share/images/NoSunrise.png
t/1_pm_compile.t
t/2_pl_compile.t
t/CN_to_VCF.t
Expand Down
Binary file modified perl/docs.tar.gz
Binary file not shown.
34 changes: 28 additions & 6 deletions perl/lib/Sanger/CGP/Ascat/Implement.pm
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ use PCAP::Bam;

const my $COUNT_READS => q{%s view -c %s %s};

const my $FAILED_SAMPLE_STATISTICS => qq{## WARNING ASCAT failed to generate a solution ##\nNormalContamination 0.3\nPloidy ?\nrho 0\npsi 0\ngoodnessOfFit 0\n};
const my $FAILED_SAMPLE_STATISTICS => qq{## WARNING ASCAT failed to %s ##\nNormalContamination 0.3\nPloidy ?\nrho 0\npsi 0\ngoodnessOfFit 0\n};

const my $ALLELE_COUNT_GENDER => ' -b %s -l %s -r %s -g ';

Expand All @@ -57,7 +57,6 @@ const my $GREP_ALLELE_COUNTS => q{grep -v '^#' %s >> %s};
const my @ASCAT_RESULT_FILES => qw(
%s.ASPCF.png
%s.germline.png
%s.sunrise.png
%s.tumour.png
%s.copynumber.caveman.csv
%s.copynumber.txt
Expand All @@ -66,6 +65,7 @@ const my @ASCAT_RESULT_FILES => qw(
const my @ASCAT_OPTIONAL_PNG => qw(
%s.ASCATprofile.png
%s.rawprofile.png
%s.sunrise.png
);

const my $GENDER_MIN => 5;
Expand Down Expand Up @@ -231,15 +231,22 @@ sub finalise {
}
}

my $cn_txt = File::Spec->catfile($options->{'outdir'}, sprintf('%s.copynumber.txt', $tum_name));
my $sunrise = File::Spec->catfile($options->{'outdir'}, sprintf('%s.sunrise.png', $tum_name));

if($force_complete == 1) {

my $fail_reason = 'generate a solution';
$fail_reason = 'determine any purity/ploidy profile' unless (-e $sunrise);

my $fake_file = sprintf '%s/%s.copynumber.caveman.csv', $options->{'outdir'}, $tum_name;
my $fake_csv = "$^X ";
$fake_csv .= _which('ascatFailedCnCsv.pl');
$fake_csv .= sprintf ' -r %s -o %s', $options->{'reference'}, $fake_file;
push @commands, $fake_csv;
my $samp_stat_file = sprintf '%s/%s.samplestatistics.txt', $options->{'outdir'}, $tum_name;
open my $STAT, '>', $samp_stat_file;
print $STAT $FAILED_SAMPLE_STATISTICS or die "Failed to write line to $samp_stat_file";
printf $STAT $FAILED_SAMPLE_STATISTICS, $fail_reason or die "Failed to write line to $samp_stat_file";
print $STAT "GenderChr $options->{genderChr}\n";
print $STAT "GenderChrFound $options->{genderIsMale}\n";
close $STAT;
Expand All @@ -248,13 +255,24 @@ sub finalise {
my $share_path = dirname(abs_path($0)).'/../share';
$share_path = module_dir('Sanger::CGP::Ascat::Implement') unless(-e File::Spec->catdir($share_path, 'images'));
my $img_path = File::Spec->catdir($share_path, 'images');
my $fail_png = File::Spec->catfile($img_path, 'NoSolution.png');

for my $f(@ASCAT_OPTIONAL_PNG) {
my $file = sprintf($f, $tum_name);
my $to = File::Spec->catfile($options->{'outdir'},$file);
next if(-e $to);
copy $fail_png, $to;
if($f eq '%s.sunrise.png') {
copy(File::Spec->catfile($img_path, 'NoSunrise.png'), $to);
}
else {
copy(File::Spec->catfile($img_path, 'NoSolution.png'), $to);
}
}

unless(-e $cn_txt) {
open my $CN, '>', $cn_txt;
print $CN join "\t", (q{}, 'Chromosome','Position','Log R', 'segmented LogR', 'BAF', 'segmented BAF', 'Copy number', 'Minor allele', 'Raw copy number');
print "\n";
close $CN;
}

}
Expand All @@ -265,6 +283,7 @@ sub finalise {
print $STAT "GenderChrFound $options->{genderIsMale}\n";
close $STAT;
}

my $new_vcf = $cave_cn;
$new_vcf =~ s/\.csv$/\.vcf/;
my $command = "$^X ";
Expand All @@ -287,9 +306,12 @@ sub finalise {

push @commands, $command, $sort_gz, $tabix;

my $cn_txt_gz = qq{gzip -c $cn_txt > $cn_txt.gz};
push @commands, $cn_txt_gz;

PCAP::Threaded::external_process_handler(File::Spec->catdir($tmp, 'logs'), \@commands, 0);

unlink $new_vcf;
unlink $new_vcf, $cn_txt;

PCAP::Threaded::touch_success(File::Spec->catdir($tmp, 'progress'), 0);
}
Expand Down
Binary file added perl/share/images/NoSunrise.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 2324d94

Please sign in to comment.