Commit a491ae22 authored by Sebastien Moretti's avatar Sebastien Moretti
Browse files

Other cleaning stuffs in main script

parent 17264db3
......@@ -308,7 +308,7 @@ for(my $r=0; $r<=$#original_names; $r++){
unlink("$cache/$date.blastp.$r", "$cache/$date.seq2blast.fas.$r") if ( $tmp == 0 || exists($equivalent_blast_hits[0]) );
if ( !exists($equivalent_blast_hits[0]) ){
print "\n$r ...\tNo blast result found above thresholds for $fasta_header\n\n";
buildFailureOutputFiles($r, 'No_BLASTp_Result', 'Not_searched', '');
buildFailureOutputFiles($r, 'No_BLASTp_Result', 'Not_searched');
undef $original_seq[$r];
undef $original_names[$r];
next EACH_SEQ;
......@@ -406,10 +406,10 @@ for(my $r=0; $r<=$#original_names; $r++){
if ( $resultPOS eq '' ){
if ( $failureStatus[0] ne '' ){
buildFailureOutputFiles($r, $failureStatus[1], $failureStatus[0], '');
buildFailureOutputFiles($r, $failureStatus[1], $failureStatus[0]);
}
else {
buildFailureOutputFiles($r, $equivalent_blast_hits[0], 'Alignment_failure', '');
buildFailureOutputFiles($r, $equivalent_blast_hits[0], 'Alignment_failure');
}
next HIT_LINK;
}
......@@ -709,15 +709,15 @@ sub isFastaFile{
sub fastaHeaders4ProtoGene{
my ($QueryName) = @_;
$QueryName =~ s/ +/ /g;
$QueryName =~ s{ +}{ }g;
my ($acc, $desc) = ($QueryName, $QueryName);
$acc =~ s/^ *([^ ]*) .*$/$1/;
$acc =~ s/\s+$//g;
$acc =~ s{^ *([^ ]*) .*$}{$1};
$acc =~ s{\s+$}{}g;
$acc = $acc.'_G_@@';
$desc =~ s/^ *[^ ]* *(.*)$/$1/;
$desc =~ s/^[\| \.]+//;
$desc =~ s/[\|\. ]+$//;
$desc =~ s{^ *[^ ]* *(.*)$}{$1};
$desc =~ s{^[\| \.]+}{};
$desc =~ s{[\|\. ]+$}{};
return($acc.$desc);
}
......@@ -732,10 +732,10 @@ sub getFastaHeaderAnnot{
close $BEST;
chomp($annot);
$annot =~ s/^ *[^ ]* //;
$annot =~ s/[\. ]*$//;
$annot =~ s/^ *//;
$annot =~ s/ +/ /g;
$annot =~ s{^ *[^ ]* }{};
$annot =~ s{[\. ]*$}{};
$annot =~ s{^ *}{};
$annot =~ s{ +}{ }g;
return($annot);
}
......@@ -757,7 +757,7 @@ sub reverse_trad{
); # '*' is for stop codon
my $triplet = 'nnn';
while( my ($x, $y) =each(%reverse_code) ){
while( my ($x, $y) = each(%reverse_code) ){
if ( uc($aa) eq $x ){
$triplet = $y;
last;
......@@ -1200,10 +1200,10 @@ sub prepareResults4BOJ{
my $readyname = '';
$readyname = fastaHeaders4ProtoGene($input_name);
if ( $intronLess =~ /:.+/ || $bestOne =~ /^N[CTWZG]_/ || $bestOne =~ /^AC_/ || $nameLess =~ /^N[CTWZG]_/ || $nameLess =~ /^AC_/ ){
$readyname =~ s/_G_@@/_G_${bestOne}-IntronLess _S_ $blastHit _DESC_ / if ( $nameLess eq '' );
$readyname =~ s/_G_@@/_G_${nameLess}-IntronLess _S_ $blastHit _DESC_ / if ( $nameLess ne '' );
$readyname =~ s/(.)$/$1 MATCHES_ON $description/ if ( $description ne '' );
$bestOne = $nameLess if ( $nameLess ne '' );
$readyname =~ s/_G_@@/_G_$bestOne-IntronLess _S_ $blastHit _DESC_ / if ( $nameLess eq '' );
$readyname =~ s/_G_@@/_G_$nameLess-IntronLess _S_ $blastHit _DESC_ / if ( $nameLess ne '' );
$readyname =~ s/(.)$/$1 MATCHES_ON $description/ if ( $description ne '' );
$bestOne = $nameLess if ( $nameLess ne '' );
}
else{
$readyname =~ s/_G_@@/_G_Unavailable _S_ $blastHit _DESC_ /;
......@@ -1325,7 +1325,7 @@ sub createCDSOutputFile{
if ( $pep==1 ){
my $peptide = $original_seq;
$peptide =~ s/(.)/${1}--/g;
$peptide =~ s/(.)/$1--/g;
print {$CDSP} $CDSresultat, ">$original_name\n$peptide\n";
}
my $CDSreformated = '';
......@@ -1337,7 +1337,6 @@ sub createCDSOutputFile{
$CDSreformatedSeq =~ s/([^\n]{60})/$1\n/g;
$CDSreformated .= $CDSreformatedName.$CDSreformatedSeq;
}
# print {$CDS} $CDSresultat;
print {$CDS} $CDSreformated;
close $CDS;
......@@ -1352,6 +1351,7 @@ sub createBOJOutputFile{
open(my $BOJ, '>>', "$originalMSA.boj");
print {$BOJ} $BOJresultat;
close $BOJ;
return;
}
......@@ -1361,19 +1361,20 @@ sub buildIntronlessBOJOutputFile{
my $annot = getFastaHeaderAnnot($NTstatus);
my $readyname = '';
$readyname = fastaHeaders4ProtoGene($original_name);
$NTstatus =~ s/:.+$//;
$readyname =~ s/_G_@@/_G_$NTstatus-IntronLess _S_ $BLASTstatus _DESC_ / if ( $NTname eq '' );
$readyname =~ s/_G_@@/_G_$NTname-IntronLess _S_ $BLASTstatus _DESC_ / if ( $NTname ne '' );
$readyname =~ s/(.)$/$1 MATCHES_ON $annot/ if ( $annot ne '' );
$readyname =~ s/ +/ /g;
$NTstatus =~ s{:.+$}{};
$readyname =~ s{_G_@@}{_G_$NTstatus-IntronLess _S_ $BLASTstatus _DESC_ } if ( $NTname eq '' );
$readyname =~ s{_G_@@}{_G_$NTname-IntronLess _S_ $BLASTstatus _DESC_ } if ( $NTname ne '' );
$readyname =~ s{(.)$}{$1 MATCHES_ON $annot} if ( $annot ne '' );
$readyname =~ s{ +}{ }g;
open(my $BOJ, '>>', "$originalMSA.boj");
print {$BOJ} ">$readyname\n$original_seq\n";
close $BOJ;
return;
}
sub buildFailureOutputFiles{
my ($order, $BLASTstatus, $NTstatus, $annot) = @_;
my ($order, $BLASTstatus, $NTstatus) = @_;
if ( $BLASTstatus eq 'No_BLASTp_Result' || $NTstatus eq 'PUI_unavailable' || $NTstatus eq 'No_nt_link' || $NTstatus eq 'Alignment_failure' ){
open(CDS, '>>', "$originalMSA.cds");
......@@ -1381,7 +1382,7 @@ sub buildFailureOutputFiles{
open(OUT, '>>', "$originalMSA.out");
open(BOJ, '>>', "$originalMSA.boj");
revtransBuilding($original_names[$order], $order, $BLASTstatus, $NTstatus, '', '');
revtransBuilding($original_names[$order], $order, $BLASTstatus, $NTstatus);
close CDS;
close CDSP if ( $pep==1 );
......@@ -1397,21 +1398,22 @@ sub buildFailureBOJOutputFile{
my $readyname = '';
$readyname = fastaHeaders4ProtoGene($original_name);
$readyname =~ s/_G_@@/_G_$NTstatus _S_ $BLASTstatus _DESC_ /;
$readyname =~ s/ +/ /g;
open( my $BOJ, '>>', "${originalMSA}.boj");
$readyname =~ s{_G_@@}{_G_$NTstatus _S_ $BLASTstatus _DESC_ };
$readyname =~ s{ +}{ }g;
open( my $BOJ, '>>', "$originalMSA.boj");
print {$BOJ} ">$readyname\n$original_seq\n";
close $BOJ;
return;
}
sub revtransBuilding{
my ($oriname, $order, $BLASTstatus, $NTstatus, $readyname, $annot) = @_;
my ($oriname, $order, $BLASTstatus, $NTstatus) = @_;
$readyname = fastaHeaders4ProtoGene($oriname);
$readyname =~ s/_G_@@/_G_$NTstatus _S_ $BLASTstatus _DESC_ /;
$readyname .= " MATCHES_ON $annot" if ($annot ne '');
$readyname =~ s/ +/ /g;
my $readyname = '';
$readyname = fastaHeaders4ProtoGene($oriname);
$readyname =~ s{_G_@@}{_G_$NTstatus _S_ $BLASTstatus _DESC_ };
$readyname =~ s{ +}{ }g;
print OUT "$readyname\n";
if ( $revtrans==1 ){
......@@ -1420,15 +1422,15 @@ sub revtransBuilding{
my $aa = substr($original_seq[$order], $w, 1);
$final_seq = $final_seq.reverse_trad($aa);
}
$readyname =~ s/_G_$NTstatus _S_ $BLASTstatus /_G_revtrans /;
my $CDSreformatedSeq = $final_seq."---\n";#FIXME: For stop codon ???
$CDSreformatedSeq =~ s/([^\n]{60})/$1\n/g;
$readyname =~ s{_G_$NTstatus _S_ $BLASTstatus }{_G_revtrans };
my $CDSreformatedSeq = $final_seq."---\n"; #FIXME: For stop codon ???
$CDSreformatedSeq =~ s{([^\n]{60})}{$1\n}g;
chomp $CDSreformatedSeq if ( $CDSreformatedSeq =~ /\n+$/ );
print CDS "$readyname\n$CDSreformatedSeq";
if ( $pep==1 ){
my $peptide = $original_seq[$order];
$peptide =~ s/(.)/$1--/g;
$peptide =~ s{(.)}{$1--}g;
print CDSP "$readyname\n$final_seq---\n$original_names[$order]\n$peptide\n";
}
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment