Commit 285c83e3 authored by Sebastien's avatar Sebastien

Ajout de la fonction CreatePanProteome by Martial

parent 8a0f540e
......@@ -102,6 +102,8 @@ MAIN:
&ExtractSpecificAndOrthologousProteins($rh_orthomcl, $rh_species, $o_param->Get('outdir'));
&ListGroupAndUniqueForAllProteomes($rh_orthomcl, $rh_species, $o_param->Get('outdir'));
&CreatePanProteome($rh_orthomcl,$rh_species,$rh_analysis_params,$o_param->Get('outdir'));
&CopyInputDataIntoOutdir($rh_analysis_params, $rh_species, $o_param->Get('outdir'));
&BuildSummaryFile($rh_analysis_params, $o_param->Get('outdir'));
......
......@@ -3,5 +3,6 @@ require 'OrthomclCompanion/Utils.pl';
require 'OrthomclCompanion/Parsers.pl';
require 'OrthomclCompanion/SpecificAndOrthologousProteins.pl';
require 'OrthomclCompanion/GroupAnalyses.pl';
require 'OrthomclCompanion/CreatePanProteome.pl';
1;
=head2 function CreatePanProteome
Title : CreatePanProteome
Usage : &CreatePanProteome($rh_orthomcl,$rh_species,$rh_analysis_params,$o_param->Get('outdir'))
Prerequisite : none
Function : Find for each proteome, the list of all group with a protein of this proteome + unique protein. Priority select seq from ref proteome then longer seq.
Returns : none
Args : hash ref of orthomcl groups, hash ref of species, outdir
Globals : none
=cut
sub CreatePanProteome
{
my ($rh_orthomcl, $rh_species, $rh_analysis_params, $outdir) = @_;
&Log("INFO - CreatePanProteome");
my $rh_specific = {};
my $refexist;
my @references;
my @SeqS1,@AllSeqS1;
my %ListGroupSelectSeqidCode;
foreach my $code (keys %{$rh_analysis_params->{'proteomes'}})
{
if ($rh_analysis_params->{'proteomes'}->{$code}->{'reference'} eq 'true')
{
push @references, $code;
}
}
foreach my $code (keys %{$rh_species})
{
$rh_specific->{$code} = Storable::dclone($rh_species->{$code}->{'sequences'});
}
foreach my $groupid (keys %{$rh_orthomcl})
{
&__DeleteSequencesFromGroupId($rh_orthomcl, $rh_specific, $groupid);
}
foreach my $group (keys %{$rh_orthomcl})
{
$refexist = 0;
@AllSeqS1 = ();
foreach my $code (@references)
{
if(exists($rh_orthomcl->{$group}->{$code}))
{
$refexist = 1;
foreach my $seqid (@{$rh_orthomcl->{$group}->{$code}})
{
@SeqS1 = ();
push @SeqS1, $code, $seqid;
push @AllSeqS1,[ @SeqS1 ];
}
}
}
if ($refexist == 0)
{
foreach my $code (keys %{$rh_orthomcl->{$group}})
{
foreach my $seqid (@{$rh_orthomcl->{$group}->{$code}})
{
@SeqS1 = ();
push @SeqS1, $code, $seqid;
push @AllSeqS1, [ @SeqS1 ];
}
}
}
$ListGroupSelectSeqidCode{$group} = &SelectSequenceRepGroupe($rh_species,\@AllSeqS1);
}
&PrintPanProteome($outdir,$rh_specific,\%ListGroupSelectSeqidCode,$rh_species);
return;
}
=head3 function SelectSequenceRepGroupe
Title : SelectSequenceRepGroupe
Usage : @selec = &SelectSequenceRepGroupe($rh_species,\@AllSeqS1);
Prerequisite : none
Function : Select representative sequence
Returns : array of [code,seqid]
Args : hash of species, array of array of [code,seqid]
Globals : none
=cut
sub SelectSequenceRepGroupe
{
my ($rh_species, $SeqForSelect) = @_;
my $selecSeqid = "";
my$selecCode = "";
foreach my $toselect (@{$SeqForSelect})
{
if ($selecSeqid eq "")
{
$selecSeqid = $toselect->[1];
$selecCode = $toselect->[0];
}
else
{
my $nb_X_selec = ($rh_species->{$selecCode}->{'sequences'}->{$selecSeqid}->{'sequence'} =~ tr/X/X/);
my $nb_X_toselec = ($rh_species->{$toselect->[0]}->{'sequences'}->{$toselect->[1]}->{'sequence'} =~ tr/X/X/);
if ((length($rh_species->{$toselect->[0]}->{'sequences'}->{$toselect->[1]}->{'sequence'}) - $nb_X_toselec * 3) > (length($rh_species->{$selecCode}->{'sequences'}->{$selecSeqid}->{'sequence'}) - $nb_X_selec * 3))
{
$selecSeqid = $toselect->[1];
$selecCode = $toselect->[0];
}
}
}
return [$selecSeqid,$selecCode];
}
=head3 function PrintPanProteome
Title : PrintPanProteome
Usage : &PrintPanProteome($outdir,$rh_specific,\%ListGroupSelectSeqidCode,$rh_species)
Prerequisite : none
Function : Print pan-proteome
Returns : none
Args : outdir, hash of specific protein, hash of representative seqid/code for each orthomcl group,hash of species
Globals : none
=cut
sub PrintPanProteome
{
my ($outdir,$rh_specific,$rh_ListGroupSelectSeqidCode,$rh_species) = @_;
my $subdirectory = "pan_proteome";
my $subdirectory_description = "directory with fasta multi-sequence of pan-proteome";
mkdir "$outdir/$subdirectory";
push (@A_OUTPUT_DATA, {'directory' => $subdirectory, 'description' => $subdirectory_description});
my $fh_PanProteome = &GetStreamOut("$outdir/$subdirectory/PanProteome.fasta");
foreach my $group (sort keys %{$rh_ListGroupSelectSeqidCode})
{
print $fh_PanProteome ">".$rh_ListGroupSelectSeqidCode->{$group}[0]."|".$rh_ListGroupSelectSeqidCode->{$group}[1]."|".$group."\n";
print $fh_PanProteome $rh_species->{$rh_ListGroupSelectSeqidCode->{$group}[1]}->{'sequences'}->{$rh_ListGroupSelectSeqidCode->{$group}[0]}->{'sequence'}."\n";
}
foreach my $code (keys %{$rh_specific})
{
foreach my $seqid (keys %{$rh_specific->{$code}})
{
print $fh_PanProteome ">".$seqid."|".$code."|uniq\n";
print $fh_PanProteome $rh_species->{$code}->{'sequences'}->{$seqid}->{'sequence'}."\n";
}
}
return;
}
1;
Markdown is supported
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