Skip to content

Commit

Permalink
Merge pull request #26 from freerkvandijk/master
Browse files Browse the repository at this point in the history
Fixed bug introduced in previous version
  • Loading branch information
freerkvandijk authored Apr 22, 2017
2 parents 7d467e1 + 85addf3 commit 0c50874
Showing 1 changed file with 81 additions and 3 deletions.
84 changes: 81 additions & 3 deletions CoNVaDING.pl
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
print "#######################################\n";

######CHANGE VERSION PARAMETER IF VERSION IS UPDATED#####
my $version = "1.2.0";
my $version = "1.2.1";

##############################################################################################
##############################################################################################
Expand Down Expand Up @@ -1584,6 +1584,7 @@ sub createOutputLists{
my $shapPassCount = 0;
my $highQualAbberationCount = 0;
my @chrStarts;
my @chrStartsHOM;
my $abberationCountHOM = 0;
my $shapPassCountHOM = 0;
my $highQualAbberationCountHOM = 0;
Expand Down Expand Up @@ -1672,16 +1673,93 @@ sub createOutputLists{
$abberationCount = 0; #Reset $abberationCount to 0
$shapPassCount = 0;
}



#Perform second iteration to also write Homozygous events to output
$target = $arrayRefs[0][$m];
$target =~ s/:/\t/g;
$target =~ s/-/\t/g;
$target =~ s/^23/X/gs;
$target =~ s/^24/Y/gs;
$target =~ s/^25/MT/gs;
$gene = $arrayRefs[1][$m];
$vals = $arrayRefs[2][$m];
$vals =~ s/&&/\t/g;
$abberation = $arrayRefs[3][$m];
$quality = $arrayRefs[4][$m];
$shap = $arrayRefs[6][$m];
@array = split("\t", $target);
if ($abberation eq "HOM_DEL" || $abberation eq "HOM_DUP") { #If abberation detected, check next abberation, afterwards write to longlist file
my $nextAbberation = $arrayRefs[3][$m+1];
my $nextGene = $arrayRefs[1][$m+1];
if ($m == $lastTargetIdx){
$nextAbberation = "LAST";
$nextGene = "LAST";
}

#Extract chr and start position from target
my @array = split("\t", $target);
$chr = $array[0];
$start = $array[1];
$stop = $array[2];
if ($abberationCountHOM == 0) {
#$outputLongToWrite .= "$chr\t$start\t"; #Write event chr and start
}
push(@chrStartsHOM, $chr);
push(@chrStartsHOM, $start);
if ($quality eq ".") { #If abberation is not filtered out due to low quality autoVC or failing gene low quality, push into shortlist
$highQualAbberationCountHOM++; #Increase number of high quality abberation counts
}
#Count number of targets passing shapiro-wilk test
if ($shap >= 0.05){
$shapPassCountHOM++;
}

if ($abberation eq $nextAbberation && $gene eq $nextGene){ #If next abberation is DEL or DUP within same gene, same event extended
$abberationCountHOM++;
}else { #Not the same event anymore, write away stop position, gene and abberation
my $abberationCountToPrint = ($abberationCountHOM+1);

#Retrieve first start to print for event
$target = $arrayRefs[0][$m-$abberationCountHOM];
$target =~ s/:/\t/g;
$target =~ s/-/\t/g;
$target =~ s/^23/X/gs;
$target =~ s/^24/Y/gs;
$target =~ s/^25/MT/gs;
#Extract chr and start position from target
my @arrayP = split("\t", $target);
my $chrP = $arrayP[0];
my $startP = $arrayP[1];
#$outputLongToWrite .= "$chr\t$start\t$stop\t$gene\t$abberationCountToPrint\t$shapPassCountHOM\t$abberation\n"; #Write event end and details away
if ($highQualAbberationCountHOM > 0) { #If total abberation counts is equal to high quality calls all target of an abberation are PASS, so the event can be written to the shortlist
if ($abberationCountHOM == 0 ) {
#$outputShortToWrite .= "$chr\t$start"; #Write event chr and start
}else{
#push(@chrStarts, $chr);
#push(@chrStarts, $start);
#$outputShortToWrite .= $chrStarts[0] . "\t" . $chrStarts[1];
}
$outputShortToWrite .= "$chrP\t$startP\t$stop\t$gene\t$abberationCountToPrint\t$shapPassCountHOM\t$abberation\n"; #Write high quality events
}
$abberationCountHOM = 0; #Reset $abberationCount to 0
$shapPassCountHOM = 0;
$highQualAbberationCountHOM = 0; #Reset $highQualAbberationCount to 0
undef(@chrStartsHOM); undef($chr); undef($start); undef($stop);
}
}else{
#Undef chr, start array and variables
undef(@chrStartsHOM); undef($chr); undef($start); undef($stop);
$abberationCountHOM = 0; #Reset $abberationCount to 0
$shapPassCountHOM = 0;
}
}
writeOutput($outputfileTotal, $outputTotalToWrite); #Write output to above specified file
writeOutput($outputfileLong, $outputLongToWrite); #Write output to above specified file
writeOutput($outputfileShort, $outputShortToWrite); #Write output to above specified file
undef(@arrayRefs); undef($outputTotalToWrite); undef($outputLongToWrite); undef($outputShortToWrite);
undef(%geneCounts);
undef(%totalGeneCounts);

}

sub allTargetNormalization {
Expand Down

0 comments on commit 0c50874

Please sign in to comment.