annotate pangenomeCogAnalysis.pl @ 13:45cc191a3290 draft

Uploaded
author mgarnier
date Thu, 19 Aug 2021 13:39:14 +0000
parents
children 574fece473bf
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
13
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1 #!/usr/bin/perl
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
2
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
3 use strict;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
4 use warnings;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
5
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
6 my $num_args = $#ARGV + 1;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
7 if ($num_args != 11) {
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
8 print "Il n'y a pas le bon nombre d'arguments !\n";
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
9 exit;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
10 }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
11
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
12 # INPUT_
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
13 my $matrix_file = $ARGV[0]; # fichier tabulé : une liste d'orthogroupes qui se retrouvent ou non dans les différentes souches
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
14 my $species_file = $ARGV[1]; # association de chaque souche à son espèce (fichier tabulé également)
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
15 my $annotation = $ARGV[2]; # collection de fichiers tabulés qui contiennent pour chaque gène la ou les catégories de COG associée(s)
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
16 my $order = $ARGV[3]; # cette entrée correspond simplement au nom des souches qui sont rentrées dans le même ordre que les fichiers d'annotation : cela permet de savoir pour un fichier COG à quelle souche et donc plus tard à quelle espèce il correspond
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
17 my $annotation_GFF = $ARGV[4]; # fichiers avec les GFF
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
18 # my $order_GFF = $ARGV[5];
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
19
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
20 # OUTPUT_
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
21 my $output = $ARGV[5]; # liste des espèces avec leurs orthogroupes (présence-absence)
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
22 my $output2 = $ARGV[6]; # fichier des moyennes
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
23 my $output3 = $ARGV[7]; # fichier de la liste des valeurs pour chaque catégorie de COG et pour chaque espèce
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
24 my $output4 = $ARGV[8]; # fichier avec les catégories de COG pour core-génome / génome accessoire / gènes spé
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
25 my $output7 = $ARGV[9];
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
26 my $output8 = $ARGV[10];
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
27 # my $output9 = $ARGV[11];
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
28
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
29
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
30 #print "ok\n";
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
31 #exit;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
32
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
33 my @list_gff = split(',', $annotation_GFF); # liste des différents fichiers GFF (qui se retrouvent dans le dossier Annotation Maker)
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
34 my %hSpecies = (); # HASH -> key: N_Id (ex NF_AR12) ; val: nom de l'esp (ex Naegleria Fowleri)
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
35
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
36 ######################## LE SPECIES_FILE ###########################
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
37 open (S, $species_file);
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
38 while (my $line = <S>){
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
39
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
40 $line =~s/\n//g; $line =~s/\r//g;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
41 my @sp = split('\t', $line);
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
42 # print "$line\n";
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
43 # exit;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
44 $hSpecies{$sp[0]} = $sp[1]; # HASH -> key: N_Id ; val: name
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
45
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
46 }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
47 my $nbr = keys (%hSpecies); #compter le nombre de souches max
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
48 # = taille de la table de hash
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
49 # print "J'ai $nbr clés\n";
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
50 # exit;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
51
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
52 close (S);
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
53
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
54 #///////////////////////////////////////////////////////////////////////////////////////////////////
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
55
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
56 ############################################ LA MATRICE ############################################
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
57
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
58 open(M, $matrix_file);
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
59
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
60 my $first_line = <M>;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
61 $first_line =~s/\n//g; $first_line =~s/\r//g; # ne garder que la première ligne du tableau
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
62 my @samples = split(/\t/,$first_line); # mettre dans une liste (@samples) chaque intitulé de colonne = N_Id
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
63 # print "$first_line\n";
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
64 # exit;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
65
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
66 # Le but ici est de récupérer les combinaisons associées à chaque espèce : NF, NG et NL
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
67 my %hCombination =(); # HASH -> key: esp ; val: combinaison
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
68
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
69 for (my $i=1; $i <= $#samples; $i++){ # on parcourt chaque colonne ($i) mais on ne regarde que le N_Id
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
70 my $header = $samples[$i]; # on récupère le N_Id dans $header (soit le nom de la colonne i)
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
71 my $species = $hSpecies{$header}; # on regarde dans la table avec N_Id => Nom esp et on attribue à chaque header (qui est ici une clé) sa valeur donc son nom d'esp correspondant
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
72 $hCombination{$species} .= "_".$i; # à chaque tour de boucle, pour une $species spé va ajouter le n° de colonne $i pour avoir la combinaison spé à chaque esp
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
73 # print "$header\n";
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
74 # exit;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
75 }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
76
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
77
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
78 # foreach my $species (keys (%hCombination)){
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
79 # my $combination = $hCombination{$species};
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
80 # print "$species $combination\n";
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
81 # }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
82
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
83
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
84 # exit;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
85
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
86 # orthogrp présents :
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
87 my %hCombination_prs = (); # HASH -> key: combinaison ; val: liste des orthogroupes
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
88 # orthogrp absents :
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
89 my %hCombination_abs = (); # idem
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
90
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
91
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
92
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
93 my %coregenes = (); # HASH -> key: gene ; val: orthogroupe (pour core-genome)
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
94 my %specificgenes = (); # HASH -> key: gene ; val: orthogroupe (pour gènes spécifiques)
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
95 my %accessorygenes = (); # HASH -> key: gene ; val: orthogroupe (pour génome accessoire)
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
96
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
97 my $coregene_line;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
98 my %coregenes2 = (); # HASH -> key1: colonne i ; key2: gène ; val: orthogroupe
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
99 my %specificgenes2 = (); # HASH -> key1: colonne i ; key2: gène ; val: orthogroupe
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
100
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
101 my %Genes_of_OG = (); # HASH -> key1: orthogroupe ; key2: colonne i ; val: gène
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
102
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
103 my %coregenes3 = (); #ligne complete
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
104 my %Type_count_byStrain = ();
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
105 my %OG_genes = ();
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
106 my $nb_genes_total = 0;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
107 my %specificgenes3 = ();
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
108 my %Species_Total_Count = (); # HASH -> key: espèce ; val: comptage du nombre total de gènes pour cette espèce
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
109 my %Genes_Species_Total = ();
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
110 my %NonStrict_Spe = ();
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
111
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
112 while(<M>) {
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
113
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
114 my $line = $_;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
115 $line =~s/\n//g; $line =~s/\r//g;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
116 my $nb_found = 0;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
117 my @infos = split(/\t/,$line);
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
118 my $orthogroup = $infos[0]; # on récupère le nom de l'orthogroupe dans $orthogroup
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
119 my $first_column = $infos[1]; # ici on récupère les gènes de la première colonne qui vont nous servir pour le core-génome
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
120 my $combi_prs = "";
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
121 my $combi_abs = "";
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
122 my $val;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
123 my $gene_random;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
124 my $unique_col_detected;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
125 my %comptage_especes;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
126 my $seule_espece;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
127
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
128 for (my $i=1; $i <= $#infos; $i++){ # on travaille par ligne puis dans chaque ligne (while(<M>)), cellule par cellule (cette boucle for)
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
129
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
130 $val = $infos[$i]; # on récupère l'information contenue dans la case $i
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
131
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
132 if ($val =~/\w/){ # s'il cette cellule contient qq chose...
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
133 $combi_prs .= "_".$i; # ...on va concaténer notre chaine $combi_prs pour que cela forme une combinaison
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
134 $nb_found++; # on incrémente le compteur qui permet de savoir cb de fois notre orthogroupe est présent (le but sera de l'utiliser quand nb_found == 9)
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
135 $gene_random=$val; # on récupère la valeur de la case (les gènes)
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
136 $unique_col_detected = $i;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
137 my $espece = $hSpecies{$samples[$i]};
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
138
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
139 my @table_genes = split (',', $val);
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
140 my $premier_gene = $table_genes[0];
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
141 # $Genes_of_OG{$i}{$orthogroup} = $premier_gene; # pour chaque orthorgoupe de chaque colonne, on récupère le premier gène
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
142 foreach my $genes (@table_genes){
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
143 # $OG_genes{$orthogroup}{$genes} = 1;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
144 $Genes_of_OG{$i}{$orthogroup} .= $genes;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
145 $nb_genes_total++;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
146 $Species_Total_Count{$espece}++;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
147 $Genes_Species_Total{$genes} = $espece;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
148 $seule_espece = $espece;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
149 $comptage_especes{$espece} .= $genes;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
150
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
151 }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
152 }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
153
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
154 else { # si jamais il n'y a rien dans la cellule...
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
155 $combi_abs .= "_".$i; # ... on fait la même chose mais avec $combi_abs
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
156 }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
157
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
158 }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
159
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
160 if (scalar keys(%comptage_especes) == 1){
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
161 my $list = $comptage_especes{$seule_espece};
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
162 my @table = split(" ",$list);
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
163 foreach my $gene (@table){
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
164 $NonStrict_Spe{$gene} = $seule_espece;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
165 }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
166 # print $_;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
167 # print $list."\n";
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
168 }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
169
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
170 # $hCount{$combi}++;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
171 $hCombination_prs{$combi_prs}.=$orthogroup."\n"; # à la fin de chaque ligne, on va ajouter notre orthogroupe à la combinaison qui lui correspond
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
172 $hCombination_abs{$combi_abs}.=$orthogroup."\n";
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
173
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
174
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
175
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
176 if ($nb_found == $#infos){ # si nb_found = au nombre de souche, c'est qu'on a à faire à un core-génome
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
177 # print "$orthogroup\n";
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
178 # print "$nb_found\n=================\n";
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
179
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
180 for (my $i=1; $i <= $#infos; $i++){
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
181 my @list_of_genes = split (',', $infos[$i]); # ici va séparer tous les gènes (qui se présentent comme une liste, séparés par des ',')
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
182 foreach my $gene (@list_of_genes){
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
183 $coregenes3{$samples[$i]}{$gene} = 1;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
184 $Type_count_byStrain{"core"}{$samples[$i]}{"oui"}++;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
185 $Type_count_byStrain{"accessory"}{$samples[$i]}{"non"}++;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
186 $Type_count_byStrain{"unique"}{$samples[$i]}{"non"}++;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
187
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
188 }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
189
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
190 # $coregenes{$first_gene}= $orthogroup; # on va récupérer ce premier gène qu'on met dans un hash (pour y avoir accès facilement, d'où val = 1, ici ça n'a pas d'importance)
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
191 # $coregenes2{$i}{$first_gene}= $orthogroup;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
192
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
193 }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
194 my @liste_of_genes = split (',', $gene_random);
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
195 my $first_gene = $liste_of_genes[0];
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
196 $coregenes{$first_gene}= $orthogroup;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
197
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
198
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
199 if (!$coregene_line){
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
200 $coregene_line = $line;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
201 }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
202 }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
203
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
204 elsif ($nb_found == 1) { # si on a un gène spé
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
205
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
206 # # print "$gene_random\n";
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
207 # # print "$line\n";
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
208 # # print "$unique_col_detected\n";
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
209
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
210
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
211 for (my $i=1; $i <= $#infos; $i++){
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
212 my @list_of_genes = split (',', $infos[$i]); # ici va séparer tous les gènes (qui se présentent comme une liste, séparés par des ',')
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
213 foreach my $gene (@list_of_genes){
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
214 $specificgenes3{$samples[$i]}{$gene} = 1;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
215 $Type_count_byStrain{"unique"}{$samples[$i]}{"oui"}++;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
216 $Type_count_byStrain{"core"}{$samples[$i]}{"non"}++;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
217 $Type_count_byStrain{"accessory"}{$samples[$i]}{"non"}++;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
218
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
219 }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
220
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
221
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
222 }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
223 # my @list_of_genes = split (',', $gene_random); # idem, on ne veut qu'un seul gène donc on crée la liste
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
224 # my $first_gene = $list_of_genes[0]; # on ne prend que le premier
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
225 # # print "$first_gene\n";
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
226 # # exit;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
227 # $specificgenes{$first_gene}= $orthogroup; # et pareil on crée la table de hash
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
228 # $specificgenes2{$unique_col_detected}{$first_gene}= $orthogroup;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
229 }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
230
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
231 else { # là c'est le génome accessoire, i.e tout le reste !
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
232 # for (my $i=1; $i <= $#infos; $i++){
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
233 # my @list_of_genes = split (',', $infos[$i]); # ici va séparer tous les gènes (qui se présentent comme une liste, séparés par des ',')
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
234 # my $first_gene = $list_of_genes[0]; # prend la valeur du premier gène uniquement !
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
235 # $accessorygenes{$first_gene}= $orthogroup; # on va récupérer ce premier gène qu'on met dans un hash (pour y avoir accès facilement, d'où val = 1, ici ça n'a pas d'importance)
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
236
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
237
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
238 # }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
239
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
240 for (my $i=1; $i <= $#infos; $i++){
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
241 my @list_of_genes = split (',', $infos[$i]); # ici va séparer tous les gènes (qui se présentent comme une liste, séparés par des ',')
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
242 foreach my $gene (@list_of_genes){
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
243 # $coregenes3{$samples[$i]}{$gene} = 1;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
244 $Type_count_byStrain{"accessory"}{$samples[$i]}{"oui"}++;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
245 $Type_count_byStrain{"core"}{$samples[$i]}{"non"}++;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
246 $Type_count_byStrain{"unique"}{$samples[$i]}{"non"}++;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
247 }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
248
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
249
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
250
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
251 }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
252
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
253
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
254 my @liste_of_genes = split (',', $gene_random);
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
255 my $first_gene = $liste_of_genes[0];
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
256 $accessorygenes{$first_gene}= $orthogroup;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
257 }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
258
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
259 }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
260
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
261 #print scalar keys(%Genes_of_OG);exit;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
262 # print "$nb_genes_total\n";
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
263
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
264 # foreach my $og (keys %OG_genes) {
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
265 # foreach my $gene (keys %{$OG_genes{$og}}) {
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
266 # # print "$og\t$gene\n";
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
267 # print $OG_genes{$og}."\n";
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
268 # }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
269 # }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
270 # exit;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
271 # foreach my $gene (keys (%Genes_Species_Total)) {
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
272 # print "$gene => ".$Genes_Species_Total{$gene}."\n";
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
273 # }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
274 # foreach my $strain (keys %specificgenes3) {
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
275 # foreach my $gene (keys %{$specificgenes3{$strain}}) {
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
276 # print "$strain\t$gene\n";
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
277 # }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
278 # }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
279 # foreach my $gene (keys (%NonStrict_Spe)){
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
280 # print $NonStrict_Spe{$gene}."\t$gene \n";
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
281 # }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
282 # exit;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
283
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
284 my %hCol_Annotated = (); # HASH -> key: colonne ; val: 1 (colonnes pour lesquelles les GFF sont présents)
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
285
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
286 # Le but ici est de ne garder que les colonnes (donc les souches) qui ont un fichier GFF associé
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
287 my @list_column = split ('\t', $coregene_line);
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
288 for (my $i=1; $i <= $#list_column; $i++){
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
289 my @list_genes = split (', ', $list_column[$i]);
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
290 my $premier_gene = $list_genes[0];
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
291 my $strain = $samples[$i]; # récupérer le nom de la souche
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
292
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
293
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
294 foreach my $gff (@list_gff){
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
295 my $result_grep = `grep $premier_gene $gff`;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
296
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
297 if ($result_grep){
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
298 $hCol_Annotated{$i}=$strain;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
299
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
300 }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
301 # print "$result_grep\n";
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
302 }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
303 }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
304 # exit;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
305 # foreach my $i (sort keys (%specificgenes2)){ # parcours de la table %hCount2 au niveau des catégories
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
306 # foreach my $gene (keys %{$specificgenes2{$i} }){ # parcours de la table %hCount2 au niveau des espèces
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
307 # print "$i\t$gene\t".$specificgenes2{$i}{$gene}."\n";
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
308 # }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
309 # }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
310 # exit;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
311 # while (my ($k,$v) = each(%accessorygenes)) {
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
312 # print "gene=$k OG=$v\n";
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
313 # }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
314 # exit;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
315 # foreach my $oups (keys (%coregenes)) {
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
316 # print "$oups\n";
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
317 # }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
318 # exit;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
319
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
320 close (M);
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
321
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
322 my %Hash_Specific = (); # HASH -> key: orthogroupe ; val: espèce
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
323
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
324 open (OUT, '>', $output) or die $!;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
325 # print OUT "$annotation\n";
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
326 foreach my $species (keys (%hCombination)){ # parcours de la table de hash %hCombination (key: nom esp ; val: combi)
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
327 my $combination = $hCombination{$species}; # on récupère dans la variable $combination la valeur de chaque clé {species} (= nom esp) de la table de hash %hCombination
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
328 my $ortho_presents = $hCombination_prs{$combination}; # $ortho_presents prend la valeur de chaque clé {combination} (récupérée juste au-dessus) de la table de hash %hCombination
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
329 my $ortho_absents = $hCombination_abs{$combination}; # en somme on a 3 combi possibles (_1_2_3_4_5 | _6 | _7_8_9) donc pour ces 3 combi-là, qui sont les clés de %hCombination_prs ou_abs, on va retrouver la liste des orthogroupes qui correspondent
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
330
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
331 # open (OUT,">results.list.txt");
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
332
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
333 if ($ortho_presents){
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
334 print OUT "> $species - present\n";
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
335 print OUT "$ortho_presents\n";
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
336 my @orthogroups_name = split ('\n', $ortho_presents);
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
337 foreach my $ortho (@orthogroups_name){
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
338 $Hash_Specific{$ortho} = $species;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
339 }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
340 }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
341
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
342 if ($ortho_absents){
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
343 # open (OUT2,">$species.$combination.absents.list.txt");
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
344 print OUT "> $species - absent\n";
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
345 print OUT "$ortho_absents\n";
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
346 }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
347
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
348 # close(OUT2);
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
349 }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
350
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
351 close(OUT);
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
352
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
353 my %Gene_Specie_Spe = (); # HASH -> key: gène spé ; val: espèce
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
354 my %Species_Spe_Count = (); # HASH -> key: espèce ; val: comptage du nombre de gènes spécifiques à cette espèce
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
355
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
356 foreach my $i (keys(%Genes_of_OG)){
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
357 foreach my $ortho (keys %{$Genes_of_OG{$i}}){
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
358 my $gene = $Genes_of_OG{$i}{$ortho};
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
359
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
360 if ($Hash_Specific{$ortho}){
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
361 my $specie = $Hash_Specific{$ortho};
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
362
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
363 my @liste_genes = split(' ',$gene);
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
364 foreach my $g(@liste_genes){
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
365 $Gene_Specie_Spe{$g} = $specie;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
366 $Species_Spe_Count{$specie}++;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
367
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
368 }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
369
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
370 }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
371 }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
372 }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
373
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
374
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
375 # exit;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
376
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
377 # my @table_keys = ();
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
378 my $nb_groupSpe_genes = 0;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
379
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
380 foreach my $gene (keys (%Gene_Specie_Spe)) {
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
381 my @table_keys = split (' ', $gene);
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
382 foreach my $unique_gene (@table_keys) {
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
383 $nb_groupSpe_genes++;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
384 }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
385 }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
386
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
387 # print scalar keys (%Gene_Specie_Spe)."\n";
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
388 # while (my ($k,$v) = each(%Gene_Specie_Spe)) {
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
389 # if ($v =~/ruberi/) {
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
390 # print "gene=$k espece=$v\n";
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
391 # }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
392 # }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
393 # foreach my $sp (keys (%Species_Spe_Count)){
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
394 # print "$sp => ".$Species_Spe_Count{$sp}."\n";
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
395 # }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
396 # exit;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
397 #//////////////////////////////////////////////////////////////////////////////////////////////////
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
398
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
399 ############################################### COG ###############################################
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
400
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
401 # STEP 1 : CORRESPONDANCE ENTRE LES DIFFERENTS FICHIERS DE COG ET L'ORDRE --------------------------------------------
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
402 my @files = split(',', $annotation); # liste des différents fichiers COG (qui se retrouvent dans le dossier Naegleria)
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
403 my @list = split(',', $order); # liste de l'ordre des souches
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
404 #my ($f,$l);
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
405
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
406 my %hCorrespondance = (); #HASH -> key: un fichier COG ; val: un nom de souche (ces 2 données sont entrées en input = $annotation et $order)
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
407
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
408 # ++++++++++++ parcours de 2 listes en même temps ++++++++++++ #
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
409 my $l = 1;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
410 foreach my $f (@files){
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
411 $hCorrespondance{$f} = $list[$l]; # on fait correspondre pour chaque fichier de COG, un nom de souche
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
412 $l++;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
413 }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
414
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
415
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
416
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
417
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
418 # #Affichage du hash
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
419 # foreach my $f (keys %hCorrespondance){
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
420 # print $f."=>".$hCorrespondance{$f}."\n"
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
421 # }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
422 # exit;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
423
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
424 # STEP 2 : POUR CHAQUE FICHIER DE COG, FAIRE CORRESPONDRE L'ESPECE (ET NON LA SOUCHE) -------------------------------------
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
425 my %hCorresp_file_species = (); # HASH -> key: un fichier de COG ; val: une espèce
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
426 my %species_names; # HASH -> key: nom d'espèce ; val: 1
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
427
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
428 foreach my $h (keys (%hCorrespondance)){ # parcours de la table de hash {fichier COG => nom souche}
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
429 my $smpl = $hCorrespondance{$h}; # $smpl prend la valeur de la clé (donc d'un nom de souche)
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
430 my $espece = $hSpecies{$smpl}; # on regarde la correspondance entre ce $smpl et les nom qu'on a dans notre table de hash %hSpecies (fichier "species.txt") pour avoir le nom de l'espèce dans $espece
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
431 $species_names{$espece} = 1; # on garde sous le coude nos nom d'espèce dans cette nouvelle table de hash
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
432 $hCorresp_file_species{$h} = $espece; # BUT ATTEINT : on donne pour chaque fichier de COG le nom de l'espèce qui lui correspond
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
433 }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
434 # while (my ($k,$v) = each(%hCorresp_file_species)) {
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
435 # print "file=$k sp=$v\n";
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
436 # }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
437 # exit;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
438
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
439
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
440
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
441
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
442 # STEP 3 : COMPTAGE DES CATEGORIES DE COG ------------------------------------------------------------------------------
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
443 my %hCount2 = (); # HASH -> key1: catégorie de COG ; key2: espèce associée ; val: comptage
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
444
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
445 # comptage du core-genome / des gènes spé / du génome accessoire
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
446 my %hCore_Count = (); # HASH -> key: catégorie de COG ; val: comptage (ce hash ne sera utilisé que pour le core-genome)
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
447 my %hSpecific_Count = (); # HASH -> key: catégorie de COG ; val: comptage
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
448 my %hAccessory_Count = (); # HASH -> key: catégorie de COG ; val: comptage
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
449
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
450 # hash pour récupérer le gène
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
451 my %hCore_Cat = (); # HASH -> key: catégorie de COG ; val: gène
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
452 my %hAccessory_Cat = (); # HASH -> key: catégorie de COG ; val: gène
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
453 my %hSpecific_Cat = (); # HASH -> key: catégorie de COG ; val: gène
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
454
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
455 # hash pour récupérer le gène
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
456 my %hCore_Cat_Esp = (); # HASH -> key1: catégorie de COG ; key2: espèce ; val: gène
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
457 my %hAccessory_Cat_Esp = (); # HASH -> key1: catégorie de COG ; key2: espèce ; val: gène
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
458 my %hSpecific_Cat_Esp = (); # HASH -> key1: catégorie de COG ; key2: espèce ; val: gène
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
459
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
460 my %Acc_Cat_Esp_Count = (); # HASH -> key1: catégorie de COG ; key2: espèce ; val: comptage
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
461
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
462 my %Cog_of_gene = (); # HASH -> key: gène ; val: cat de COG
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
463 my %Cogs_of_gene = (); # HASH -> key: gène ; val: cat de COG (plusieurs)
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
464 my %Specie_of_gene = (); # HASH -> key: gène ; val: souche
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
465
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
466 my %Global_Count = ();
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
467 my %Species_Count = ();
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
468 my %Species_NonStrictSpe_Count = ();
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
469
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
470 my %Genes_in_COG = ();
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
471 my %Count_Spe_Genes = ();
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
472 my %Count_Total_Species = ();
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
473 my %Count_NonStrictSpe_Genes = ();
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
474
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
475 my %Nveau = ();
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
476
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
477
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
478 foreach my $file(@files){ # parcours de la liste des fichiers
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
479 my $esp = $hCorresp_file_species{$file}; # on récupère l'espèce pour chaque fichier de COG dans $esp
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
480 # print $esp."\n";
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
481 # exit;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
482
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
483 my %hCount = (); # HASH -> key: catégorie de COG ; val: comptage
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
484
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
485
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
486 open (A, $file); # on va parcourir maintenant chaque fichier un à un
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
487 my $strain = $hCorrespondance{$file};
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
488
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
489 while (my $line2 = <A>){
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
490
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
491 $line2 =~s/\n//g; $line2 =~s/\r//g; # on procède ligne par ligne
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
492 my @Genes = split('\t', $line2);
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
493 my $cogs = $line2;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
494 my $gene = $Genes[0];
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
495 my $cog_id = $Genes[1];
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
496 $cogs =~s/$gene//g; $cogs =~s/$cog_id//g;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
497 my $first_cat = $Genes[2];
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
498 $Cog_of_gene{$gene} = $first_cat;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
499 $Cogs_of_gene{$gene} = $cogs;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
500
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
501 $Genes_in_COG{$gene} = $esp;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
502
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
503 for (my $j=2; $j <= $#Genes; $j++) {
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
504 my $cat = $Genes[$j]; # on récupère la ou les catégorie(s) de COG
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
505 $hCount{$cat}++; # pour la catégorie donnée, on incrémente son nb d'occurences
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
506
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
507
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
508 if ($coregenes{$gene}){ # si le $gene fait bien partie du core-genome (donc de notre table de hash %coregenes)
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
509 $hCore_Count{$cat}++; # on incrémente le hash
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
510 $hCore_Cat{$cat}=$gene; # on récupère le nom du gène
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
511 }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
512
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
513 if ($accessorygenes{$gene}){ # s'il fait partie des gènes accessoires
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
514
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
515 $hAccessory_Count{$cat}++;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
516 $hAccessory_Cat{$cat}=$gene;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
517
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
518 # if ($accessorygenes{$gene} && $Gene_Specie_Spe{$gene}){
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
519 # print "$gene\n";
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
520 # # my $espece = $Gene_Specie_Spe{$gene};
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
521 # # print "$espece\n";
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
522 # # $Nveau{$cat}{$espece}++;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
523 # }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
524
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
525 }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
526 if ($coregenes3{$strain}{$gene}){
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
527 $Global_Count{"core"}{$cat}{$strain}{"oui"}++;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
528 $Global_Count{"accessory"}{$cat}{$strain}{"non"}++;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
529 $Global_Count{"unique"}{$cat}{$strain}{"non"}++;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
530 }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
531 elsif ($specificgenes3{$strain}{$gene}){
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
532 $Global_Count{"unique"}{$cat}{$strain}{"oui"}++;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
533 $Global_Count{"core"}{$cat}{$strain}{"non"}++;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
534 $Global_Count{"accessory"}{$cat}{$strain}{"non"}++;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
535 }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
536 else {
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
537 $Global_Count{"accessory"}{$cat}{$strain}{"oui"}++;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
538 $Global_Count{"core"}{$cat}{$strain}{"non"}++;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
539 $Global_Count{"unique"}{$cat}{$strain}{"non"}++;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
540 }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
541
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
542
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
543
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
544
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
545
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
546
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
547 if ($Gene_Specie_Spe{$gene}) {
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
548 $Species_Count{$esp}{$cat}{$strain}{"oui"}++;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
549 }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
550 else {
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
551 $Species_Count{$esp}{$cat}{$strain}{"non"}++;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
552 }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
553
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
554
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
555
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
556 if ($NonStrict_Spe{$gene}) {
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
557 $Species_NonStrictSpe_Count{$esp}{$cat}{$strain}{"oui"}++;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
558 }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
559 else {
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
560 $Species_NonStrictSpe_Count{$esp}{$cat}{$strain}{"non"}++;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
561 }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
562
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
563 # $Global_Count{$cat}{"accessory"}{$strain}++;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
564
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
565
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
566 # if ($specificgenes{$gene}){ # s'il fait partie des gènes spécifiques
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
567 # $hSpecific_Count{$cat}++;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
568 # $hSpecific_Cat{$cat}=$gene;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
569 # }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
570 # $hCount2{$cat}{$esp}++; # TABLE DE HASH AVEC CLES=CAT DE COG + ESPECE VAL=COMPTAGE
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
571
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
572
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
573 }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
574 }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
575
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
576
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
577
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
578 close (A);
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
579
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
580 # foreach my $espece (sort keys (%Species_NonStrictSpe_Count)) {
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
581 # foreach my $cat (sort keys %{$Species_NonStrictSpe_Count{$espece}}) {
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
582 # foreach my $strain (sort keys %{$Species_NonStrictSpe_Count{$espece}{$cat}}) {
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
583 # foreach my $choix (sort keys %{$Species_NonStrictSpe_Count{$espece}{$cat}{$strain}}) {
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
584
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
585 # print "$espece - $cat - $strain - $choix ". $Species_NonStrictSpe_Count{$espece}{$cat}{$strain}{$choix}."\n";
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
586 # }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
587 # }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
588
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
589 # }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
590 # }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
591 # exit;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
592
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
593 # while (my ($k,$v) = each(%hCore_Cat)) {
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
594 # print "cat=$k gene=$v\n";
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
595 # }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
596 # exit;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
597
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
598 # print "$file $esp\n=============\n";
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
599 while (my ($k,$v) = each(%hCount)) { # parcours de la table de hash de comptage
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
600 # print "cat=$k nb=$v\n";
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
601 $hCount2{$k}{$esp}.= "$v,"; # pour un $k (= une catégorie de COG) on lui associe son espèce et on donne la valeur du comptage qui vient de %hCount
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
602 # le but ici est en fait pour une espèce et une catégorie données on veut le nombre d'occurences par souche (pour NF par ex on aura 5 valeurs car il y a 5 souches)
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
603 }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
604
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
605 # Récupérer les gènes du core-génome
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
606 while (my ($cat_core,$gene_core) = each(%hCore_Cat)) {
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
607 $hCore_Cat_Esp{$cat_core}{$esp}=$gene_core;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
608 }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
609 # Récupérer les gènes du génome-accessoire
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
610 while (my ($cat_acc,$gene_acc) = each(%hAccessory_Cat)) {
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
611 $hAccessory_Cat_Esp{$cat_acc}{$esp}=$gene_acc;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
612 }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
613 # Récupérer les gènes spécifique
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
614 while (my ($cat_spe,$gene_spe) = each(%hSpecific_Cat)) {
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
615 $hSpecific_Cat_Esp{$cat_spe}{$esp}=$gene_spe;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
616 }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
617
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
618 ###
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
619 while (my ($cat,$count) = each(%hAccessory_Count)) {
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
620 $Acc_Cat_Esp_Count{$cat}{$esp}=$count;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
621 }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
622 }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
623 # foreach my $type (sort keys (%Global_Count)) {
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
624 # foreach my $cat (sort keys %{$Global_Count{$type}}) {
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
625 # foreach my $strain (sort keys %{$Global_Count{$type}{$cat}}) {
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
626 # foreach my $choix (sort keys %{$Global_Count{$type}{$cat}{$strain}}) {
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
627
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
628 # print "$type - $cat - $strain - $choix ". $Global_Count{$type}{$cat}{$strain}{$choix}."\n";
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
629 # }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
630 # }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
631
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
632 # }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
633 # }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
634 # foreach my $espece (sort keys (%Global_Count)) {
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
635 # foreach my $cat (sort keys %{$Species_NonStrictSpe_Count{$espece}}) {
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
636 # foreach my $strain (sort keys %{$Species_NonStrictSpe_Count{$espece}{$cat}}) {
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
637 # foreach my $choix (sort keys %{$Species_NonStrictSpe_Count{$espece}{$cat}{$strain}}) {
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
638
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
639 # print "$espece - $cat - $strain - $choix ". $Species_NonStrictSpe_Count{$espece}{$cat}{$strain}{$choix}."\n";
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
640 # }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
641 # }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
642
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
643 # }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
644 # }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
645 # exit;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
646
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
647 foreach my $gene (keys (%Genes_in_COG)){
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
648 my $espece = $Genes_in_COG{$gene};
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
649 if ($Gene_Specie_Spe{$gene}) {
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
650 $Count_Spe_Genes{$espece}++;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
651 }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
652 if ($Genes_Species_Total{$gene}) {
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
653 $Count_Total_Species{$espece}++;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
654 }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
655 if ($NonStrict_Spe{$gene}) {
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
656 $Count_NonStrictSpe_Genes{$espece}++;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
657 }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
658 }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
659
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
660
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
661 # #############################################
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
662 # # p / (1-p) p * (1-q) #
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
663 # # odds ratio = ----------- = ----------- #
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
664 # # q / (1-q) q * (1-p) #
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
665 # #############################################
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
666 # # où p : proba qu'un E arrive au groupe A
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
667 # # où q : proba que ce même E arrive au groupe B
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
668
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
669
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
670 my @orders = ("D","M","N","O","T","U","V","Y","Z","A","B","J","K","L","C","E","F","G","H","I","P","Q","R","S");
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
671 ###################
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
672 open (OUT7, ">$output7") or die $!;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
673
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
674 # my $nb_files = scalar keys @files;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
675
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
676
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
677 print OUT7 "\t";
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
678
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
679 foreach my $category(@orders){
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
680 # foreach my $category (sort keys (%Acc_Cat_Esp_Count)) {
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
681 # my $cat = $category."\t";
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
682 print OUT7 $category."\t";
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
683 }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
684
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
685 print OUT7 "\n";
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
686
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
687
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
688 # foreach my $category (sort keys (%Global_Count)){
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
689 foreach my $type (sort keys (%Global_Count)){
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
690
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
691 print OUT7 "$type\t";
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
692 #foreach my $category (sort keys (%{$Global_Count{$type}})){
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
693 foreach my $category(@orders){
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
694
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
695 foreach my $strain (sort keys (%{$Global_Count{$type}{$category}})){
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
696
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
697 # foreach my $type (sort keys (%{$Global_Count{$category}{$strain}})){
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
698 my $nb_type1; my $nb_type2;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
699
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
700 if ($Global_Count{$type}{$category}{$strain}{"non"} && $Global_Count{$type}{$category}{$strain}{"oui"}) {
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
701 $nb_type1 = $Type_count_byStrain{$type}{$strain}{"non"} - $Global_Count{$type}{$category}{$strain}{"non"};
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
702 $nb_type2 = $Type_count_byStrain{$type}{$strain}{"oui"} - $Global_Count{$type}{$category}{$strain}{"oui"};
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
703 }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
704 # print OUT8 "$category\t$type\t$strain\t".$Global_Count{$category}{$type}{$strain}."\t"."$nb_type\n";
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
705 my $ratio1; my $ratio2;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
706 if ($nb_type1 && $nb_type2) {
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
707 $ratio1 = $Global_Count{$type}{$category}{$strain}{"non"}/ $nb_type1;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
708 $ratio2 = $Global_Count{$type}{$category}{$strain}{"oui"} / $nb_type2;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
709 }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
710 my $odds_ratio;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
711
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
712 if ($ratio1 && $ratio2) {
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
713 $odds_ratio = $ratio2 / $ratio1;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
714 }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
715 # print $strain." ".$Type_count_byStrain{$type}{$strain}{"oui"}."\n";
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
716 # print OUT8 "$category\t$type\t$strain\t".$Global_Count{$category}{$strain}{$type}{"oui"}."\t"."$nb_type2\t".$Global_Count{$category}{$strain}{$type}{"non"}."\t"."$nb_type1\t$odds_ratio\n";
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
717 if ($odds_ratio) {
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
718 print OUT7 "$odds_ratio;";
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
719 }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
720
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
721 }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
722 print OUT7 "\t";
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
723 }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
724
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
725 print OUT7 "\n";
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
726 }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
727
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
728
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
729 print OUT7 "\n";
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
730 close (OUT7);
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
731
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
732
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
733 #//////////////////////////////////////////////
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
734 open (OUT8, ">$output8") or die $!;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
735
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
736
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
737
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
738 print OUT8 "\t";
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
739
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
740 #
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
741 foreach my $category(@orders){
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
742 print OUT8 $category."\t";
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
743 }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
744
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
745 print OUT8 "\n";
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
746
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
747
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
748 # foreach my $category (sort keys (%Global_Count)){
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
749 foreach my $specie (sort keys (%Species_Count)){
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
750 # my $nb_genes_nonSpe = $Species_Total_Count{$specie} - $Species_Spe_Count{$specie};
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
751 my $nb_genes_nonSpe = $Count_Total_Species{$specie} - $Count_Spe_Genes{$specie};
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
752
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
753 print OUT8 "$specie\t";
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
754 foreach my $category (sort keys (%{$Species_Count{$specie}})){
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
755
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
756 foreach my $strain (sort keys (%{$Species_Count{$specie}{$category}})){
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
757
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
758
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
759 my $nb_type1; my $nb_type2;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
760
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
761 if ($Species_Count{$specie}{$category}{$strain}{"non"} && $Species_Count{$specie}{$category}{$strain}{"oui"}) {
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
762 $nb_type1 = $nb_genes_nonSpe - $Species_Count{$specie}{$category}{$strain}{"non"}; # 1-q
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
763 $nb_type2 = $Count_Spe_Genes{$specie} - $Species_Count{$specie}{$category}{$strain}{"oui"}; # 1-p
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
764 # $nb_type2 = $Species_Spe_Count{$specie} - $Species_Count{$specie}{$category}{$strain}{"oui"}; # 1-p
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
765 # print "$nb_genes_nonSpe - ".$Species_Count{$specie}{$category}{$strain}{"non"}. " $nb_type1\n$nb_groupSpe_genes - ".$Species_Count{$specie}{$category}{$strain}{"oui"}. " $nb_type2\n"; exit;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
766 }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
767
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
768 # print OUT8 "$category\t$type\t$strain\t".$Global_Count{$category}{$type}{$strain}."\t"."$nb_type\n";
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
769 my $ratio1; my $ratio2;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
770 if ($nb_type1 && $nb_type2) {
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
771 $ratio1 = $Species_Count{$specie}{$category}{$strain}{"non"}/ $nb_type1;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
772 $ratio2 = $Species_Count{$specie}{$category}{$strain}{"oui"} / $nb_type2;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
773 }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
774 my $odds_ratio;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
775
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
776 if ($ratio1 && $ratio2) {
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
777 $odds_ratio = $ratio2 / $ratio1;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
778 }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
779 # print $strain." ".$Type_count_byStrain{$type}{$strain}{"oui"}."\n";
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
780 # print OUT8 "$category\t$type\t$strain\t".$Global_Count{$category}{$strain}{$type}{"oui"}."\t"."$nb_type2\t".$Global_Count{$category}{$strain}{$type}{"non"}."\t"."$nb_type1\t$odds_ratio\n";
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
781 if ($odds_ratio) {
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
782 print OUT8 "$odds_ratio;";
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
783 }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
784
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
785 }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
786 print OUT8 "\t";
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
787 }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
788 print OUT8 "\n";
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
789 }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
790
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
791 # print OUT9 "\n";
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
792
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
793 close (OUT8);
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
794
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
795 #///////////////////////////////////////////////////
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
796 # open (OUT9, '>', $output9) or die $!;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
797
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
798
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
799
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
800 # print OUT9 "\t";
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
801
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
802 # #
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
803 # foreach my $category(@orders){
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
804 # print OUT9 $category."\t";
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
805 # }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
806
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
807 # print OUT9 "\n";
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
808
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
809
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
810 # # foreach my $category (sort keys (%Global_Count)){
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
811 # foreach my $specie (sort keys (%Species_NonStrictSpe_Count)){
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
812 # # my $nb_genes_nonSpe = $Species_Total_Count{$specie} - $Species_Spe_Count{$specie};
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
813 # my $nb_genes_nonSpeNS = $Count_Total_Species{$specie} - $Count_NonStrictSpe_Genes{$specie};
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
814
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
815 # print OUT9 "$specie\t";
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
816 # foreach my $category (sort keys (%{$Species_NonStrictSpe_Count{$specie}})){
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
817
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
818 # foreach my $strain (sort keys (%{$Species_NonStrictSpe_Count{$specie}{$category}})){
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
819
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
820
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
821 # my $nb_type1; my $nb_type2;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
822
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
823 # if ($Species_NonStrictSpe_Count{$specie}{$category}{$strain}{"non"} && $Species_NonStrictSpe_Count{$specie}{$category}{$strain}{"oui"}) {
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
824 # $nb_type1 = $nb_genes_nonSpeNS - $Species_NonStrictSpe_Count{$specie}{$category}{$strain}{"non"}; # 1-q
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
825 # $nb_type2 = $Count_NonStrictSpe_Genes{$specie} - $Species_NonStrictSpe_Count{$specie}{$category}{$strain}{"oui"}; # 1-p
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
826 # # $nb_type2 = $Species_Spe_Count{$specie} - $Species_Count{$specie}{$category}{$strain}{"oui"}; # 1-p
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
827 # # print "$nb_genes_nonSpe - ".$Species_Count{$specie}{$category}{$strain}{"non"}. " $nb_type1\n$nb_groupSpe_genes - ".$Species_Count{$specie}{$category}{$strain}{"oui"}. " $nb_type2\n"; exit;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
828 # }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
829
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
830 # # print OUT8 "$category\t$type\t$strain\t".$Global_Count{$category}{$type}{$strain}."\t"."$nb_type\n";
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
831 # my $ratio1; my $ratio2;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
832 # if ($nb_type1 && $nb_type2) {
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
833 # $ratio1 = $Species_NonStrictSpe_Count{$specie}{$category}{$strain}{"non"}/ $nb_type1;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
834 # $ratio2 = $Species_NonStrictSpe_Count{$specie}{$category}{$strain}{"oui"} / $nb_type2;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
835 # }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
836 # my $odds_ratio;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
837
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
838 # if ($ratio1 && $ratio2) {
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
839 # $odds_ratio = $ratio2 / $ratio1;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
840 # }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
841 # # print $strain." ".$Type_count_byStrain{$type}{$strain}{"oui"}."\n";
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
842 # # print OUT8 "$category\t$type\t$strain\t".$Global_Count{$category}{$strain}{$type}{"oui"}."\t"."$nb_type2\t".$Global_Count{$category}{$strain}{$type}{"non"}."\t"."$nb_type1\t$odds_ratio\n";
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
843 # if ($odds_ratio) {
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
844 # print OUT9 "$odds_ratio;";
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
845 # }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
846
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
847 # }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
848 # print OUT9 "\t";
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
849 # }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
850 # print OUT9 "\n";
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
851 # }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
852
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
853 # # print OUT9 "\n";
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
854
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
855 # close (OUT9);
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
856
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
857 # exit;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
858 ########################## sortie de pourcentages ##########################
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
859 # my $somme_core = 0;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
860 # my $somme_acc = 0;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
861
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
862
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
863 # foreach my $cat (keys(%hCore_Count)){
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
864 # $somme_core = $somme_core + $hCore_Count{$cat};
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
865 # }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
866 # foreach my $category (sort keys (%Acc_Cat_Esp_Count)) {
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
867
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
868 # foreach my $especeee (keys %{$Acc_Cat_Esp_Count{$category}}) {
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
869 # $somme_acc = $somme_acc + $Acc_Cat_Esp_Count{$category}{$especeee};
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
870
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
871 # }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
872
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
873 # }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
874
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
875
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
876 # print "COG categories\tCore-genome\tAccessory genome\n"."\n";
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
877 # # foreach my $e (sort keys (%species_names)){ # on parcours le hash d'espèces...
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
878 # # print $e."\t"; #... où on récupère le nom de celles-ci
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
879 # # }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
880 # # print "\n";
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
881
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
882 # foreach my $category (sort keys (%Acc_Cat_Esp_Count)) { # parcours au niveau de la 1ere clé
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
883 # my $nb_core = 0;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
884 # my $somme_totale = 0;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
885 # my $number = 0;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
886 # print $category."\t";
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
887 # my $c = 0;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
888 # if ($hCore_Count{$category}){ # si cette catégorie existe dans le core-génome
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
889 # $c = $hCore_Count{$category};
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
890 # # $hash_core_pc{$c} = 1;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
891 # $somme_totale = $somme_totale + $c;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
892 # $nb_core = ($c/$somme_core)*100;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
893 # # print "$nb_core\t";
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
894 # }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
895
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
896 # foreach my $especes (sort keys (%species_names)) {
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
897 # my $nb_acc = 0;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
898 # my $acc = 0;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
899
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
900 # if ($Acc_Cat_Esp_Count{$category}{$especes}) { # si pour une catégorie et une espèce données, on a un nombre : $nbr prend la valeur de ce dernier
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
901 # $acc = $Acc_Cat_Esp_Count{$category}{$especes};
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
902 # $number = $number + $acc;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
903 # $somme_totale = $somme_totale + $acc;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
904 # $nb_acc = ($acc/$somme_acc)*100;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
905 # # print "$nb_acc\t";
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
906 # }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
907
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
908 # }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
909
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
910
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
911 # print "|\t";
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
912 # my $pourcentage_core = ($c/$somme_totale)*100;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
913 # print "$pourcentage_core\t";
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
914 # my $pourcentage_acc = ($number/$somme_totale)*100;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
915 # print "$pourcentage_acc\n";
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
916
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
917 # }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
918
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
919 ###
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
920 # exit;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
921
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
922
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
923 ########################## sortie de comptage ##########################
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
924 # print "COG categories\tCore-genome\tAccessory genome\n"."\t\t";
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
925 # foreach my $e (sort keys (%species_names)){ # on parcours le hash d'espèces...
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
926 # print $e."\t"; #... où on récupère le nom de celles-ci
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
927 # }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
928 # print "\n";
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
929
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
930 # foreach my $category (sort keys (%Acc_Cat_Esp_Count)) { # parcours au niveau de la 1ere clé
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
931 # print $category."\t\t";
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
932 # my $c = 0;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
933 # if ($hCore_Count{$category}){ # si cette catégorie existe dans le core-génome
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
934 # $c = $hCore_Count{$category};
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
935 # print "$c\t";
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
936 # }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
937 # foreach my $especes (sort keys (%species_names)) {
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
938 # if ($Acc_Cat_Esp_Count{$category}{$especes}) { # si pour une catégorie et une espèce données, on a un nombre : $nbr prend la valeur de ce dernier
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
939 # print $Acc_Cat_Esp_Count{$category}{$especes}."\t";
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
940
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
941 # }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
942 # }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
943
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
944
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
945 # print "\n";
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
946 # }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
947
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
948 ###
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
949
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
950 # foreach my $category (sort keys (%hCount2)) { # on parcourt de nouveau les catégories de notre hash à 2 clés
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
951 # print OUT2 $category;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
952
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
953 # foreach my $especes (sort keys (%species_names)) { # on parcourt également le hash d'espèces
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
954
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
955 # my $nbr = 0;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
956 # if ($hCount2{$category}{$especes}) { # si pour une catégorie et une espèce données, on a un nombre : $nbr prend la valeur de ce dernier
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
957 # $nbr = $hCount2{$category}{$especes};
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
958 # }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
959 # STEP 4 : AFFICHAGE DANS LE FICHIER DE SORTIE ------------------------------------------------------------------------------
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
960 open (OUT4, ">$output4") or die $!;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
961
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
962 print OUT4 "COG categories"."\t"."Core-genome"."\t"."Accessory genome"."\t"."Strain Specific genes"."\n";
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
963
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
964 foreach my $category (sort keys (%hCount2)){ # parcours de la table %hCount2 au niveau des catégories
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
965 my $c = 0;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
966 if ($hCore_Count{$category}){ # si cette catégorie existe dans le core-génome
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
967 $c = $hCore_Count{$category};
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
968 }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
969 my $acc = 0;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
970 if ($hAccessory_Count{$category}){ # si cette catégorie existe dans le génome accessoire
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
971 $acc = $hAccessory_Count{$category};
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
972 }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
973 # my $s = 0;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
974 # if ($hSpecific_Count{$category}){ # si cette catégorie existe dans les gènes spécifiques
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
975 # $s = $hSpecific_Count{$category};
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
976 # }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
977 print OUT4 "$category\t".$c."\t".$acc."\n";#.$s."\n";
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
978
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
979 foreach my $especeee (keys %{$hCount2{$category} }){ # parcours de la table %hCount2 au niveau des espèces
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
980 # print OUT4 "$especeee\t$category\t"; # affichage des esp puis des cat
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
981
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
982 # if ($hCore_Cat_Esp{$category}{$especeee}) {
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
983 # print OUT4 "$hCore_Cat_Esp{$category}{$especeee}\t";
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
984 # }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
985 my $c = 0;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
986 if ($hCore_Count{$category}){ # si cette catégorie existe dans le core-génome
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
987 $c = ($hCore_Count{$category}/scalar keys (%coregenes))*100; # calcul du % du comptage
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
988 }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
989 # print OUT4 "$c\t"; # affichage du %
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
990
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
991 # if ($hAccessory_Cat_Esp{$category}{$especeee}) {
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
992 # print OUT4 "$hAccessory_Cat_Esp{$category}{$especeee}\t";
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
993 # }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
994 my $acc = 0;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
995 if ($hAccessory_Count{$category}){ # si cette catégorie existe dans le génome accessoire
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
996 $acc = ($hAccessory_Count{$category}/scalar keys (%accessorygenes))*100; # calcul du % du comptage
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
997 }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
998 # print OUT4 "$acc\t"; # affichage du %
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
999
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1000 # # if ($hSpecific_Cat_Esp{$category}{$especeee}) {
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1001 # # print OUT4 "$hSpecific_Cat_Esp{$category}{$especeee}\t";
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1002 # # }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1003 # my $s = 0;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1004 # if ($hSpecific_Count{$category}){ # si cette catégorie existe dans les gènes spécifiques
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1005 # $s = ($hSpecific_Count{$category}/scalar keys (%specificgenes))*100; # calcul du % du comptage
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1006 # }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1007 # # print OUT4 "$s\n"; # affichage du %
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1008 }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1009 }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1010 close (OUT4);
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1011
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1012 open (OUT3, ">$output3") or die $!;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1013 foreach my $category (sort keys (%hCount2)) { # parcours au niveau de la 1ere clé
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1014
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1015 foreach my $especeee (keys %{$hCount2{$category} }) { # parcours au niveau de la 2e clé pour la $category donnée
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1016
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1017 print OUT3 "$category\t$especeee\t$hCount2{$category}{$especeee}\n"; # on crée une sortie qui affiche en somme notre hash %hCount2
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1018 }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1019 }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1020
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1021 close (OUT3);
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1022
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1023
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1024 open (OUT2, ">$output2") or die $!;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1025
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1026 print OUT2 "category";
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1027 foreach my $e (sort keys (%species_names)){ # on parcours le hash d'espèces...
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1028 print OUT2 "\t".$e; #... où on récupère le nom de celles-ci
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1029 }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1030 print OUT2 "\n";
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1031
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1032 foreach my $category (sort keys (%hCount2)) { # on parcourt de nouveau les catégories de notre hash à 2 clés
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1033 print OUT2 $category;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1034
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1035 foreach my $especes (sort keys (%species_names)) { # on parcourt également le hash d'espèces
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1036
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1037 my $nbr = 0;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1038 if ($hCount2{$category}{$especes}) { # si pour une catégorie et une espèce données, on a un nombre : $nbr prend la valeur de ce dernier
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1039 $nbr = $hCount2{$category}{$especes};
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1040 }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1041 # $nbr =~s/\n//g; $nbr =~s/\r//g;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1042
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1043
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1044 my @liste = split(',', $nbr); # vu qu'il peut y avoir plusieurs nombres on les dissocie
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1045
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1046 my $somme=0;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1047 my $n=0;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1048 my $moyenne=0;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1049 #print "\nma liste de $nbr: ".join("%",@liste)."\n";
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1050 foreach my $x (@liste) { # on parcourt nos nombres
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1051 $somme=$somme+$x;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1052 $n=$n+1;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1053 }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1054
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1055 if ($n>0){
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1056 $moyenne = $somme/$n; # on fait le calcul de la moyenne
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1057 }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1058 # print "$category, $especes: $hCount2{$category}{$especes}\t";
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1059 # print "moyenne = $moyenne\n=============\n";
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1060
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1061 print OUT2 "\t".$moyenne; # fichier de sortie
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1062 }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1063 print OUT2 "\n";
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1064 }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1065
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1066 close (OUT2);
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1067
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1068 # foreach my $cat (keys (%hCore_Cat)){
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1069 # print OUT4 $c_gene."\t";
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1070 # }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1071
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1072
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1073 #//////////////////////////////////////////////////////////////////////////////////////////////////
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1074
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1075 ############################################### GFF ###############################################
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1076
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1077
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1078 # my @order_gff = split(',', $order_GFF); # liste de l'ordre des souches
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1079 my ($g,$o);
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1080
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1081 my %hgff_order = (); #HASH -> key: un fichier GFF ; val: un nom de souche (ces 2 données sont entrées en input = $annotation_GFF et $order_GFF)
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1082 my %Gene_position = ();
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1083 my %Cat_genes = ();
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1084 my %Cat_genes2 = ();
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1085
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1086 my %hash_of_genes = ();
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1087
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1088
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1089 foreach $g (@list_gff){
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1090 # print "$g\n";
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1091 # $hgff_order{$g} = $order_gff[$o++]; # on fait correspondre pour chaque fichier GFF, un nom de souche
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1092 open (G, $g);
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1093 while (<G>) {
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1094 my @table_gff = split (/\t/, $_);
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1095 my $chr = $table_gff[0];
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1096 my $start = $table_gff[3];
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1097 my $end = $table_gff[4];
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1098 my $gene_name = $table_gff[8];
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1099 my $type = $table_gff[2];
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1100
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1101
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1102
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1103 if ($type && $type eq "mRNA" && $gene_name =~ /ID=([^;]+);/){ #or $type eq "CDS"
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1104 my $gene = $1;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1105 # print $gene."\n";
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1106 # exit;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1107 $hash_of_genes{$gene}=1;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1108
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1109 foreach my $cog (keys (%hCore_Cat)){
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1110 if ($hCore_Cat{$cog} eq $gene){
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1111 $Cat_genes{$gene}=$cog;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1112 }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1113 }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1114 foreach my $cog_bis (keys (%hSpecific_Cat)){
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1115 if ($hSpecific_Cat{$cog_bis} eq $gene){
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1116 $Cat_genes2{$gene}=$cog_bis;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1117 }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1118 }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1119
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1120 $Gene_position{$gene}="$chr\t$start\t$end";
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1121 }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1122
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1123 # foreach my $gene (keys (%hash_of_genes)){
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1124 # my $orthogrp = $hGene_OG{$gene};
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1125 # print "$orthogrp\n";
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1126 # }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1127 }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1128
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1129 close (G);
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1130 }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1131
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1132 my %Hash_Convert = ( "A"=>1, "B"=>2, "C"=>3, "D"=>4, "E"=>5, "F"=>6, "G"=>7, "H"=>8, "I"=>9, "J"=>10, "K"=>11, "L"=>12, "M"=>13, "N"=>14, "O"=>15, "P"=>16, "Q"=>17, "R"=>18,"S"=>19, "T"=>20, "U"=>21, "V"=>22, "W"=>23, "X"=>24, "Y"=>25, "Z"=>26, "unknown"=>27);
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1133
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1134 mkdir("Core");
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1135 foreach my $i (keys (%coregenes2)){
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1136
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1137 if (!$hCol_Annotated{$i}) { # si le fichier GFF n'existe pas
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1138 next;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1139 }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1140
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1141
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1142 my $strain_name = $hCol_Annotated{$i};
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1143
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1144 my $specie_name = $hSpecies{$strain_name};
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1145
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1146
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1147
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1148 open (OUT5, "> Core/$strain_name.$specie_name.txt") or die "Cannot create file $!\n";
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1149 print OUT5 "Orthogroup\tGene\tChromosome\tStart\tEnd\tCOG categories\tNumber assigned\n";
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1150
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1151 my $refcoregenes2 = $coregenes2{$i};
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1152 my %subhash = %$refcoregenes2;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1153 foreach my $gene (keys (%subhash)){
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1154 # print "$gene\n";
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1155 my $cat = "unknown";
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1156 if ($Cog_of_gene{$gene}){
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1157 $cat = $Cog_of_gene{$gene};
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1158 }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1159 # if (!$Gene_position{$gene}){
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1160 # print "$gene\n coucou"; exit;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1161 # }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1162
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1163 # if (!$subhash{$gene}){
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1164 # print "$gene\n";
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1165 # }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1166 print OUT5 $subhash{$gene}."\t"."$gene\t".$Gene_position{$gene}."\t".$cat."\t".$Hash_Convert{$cat}."\n";
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1167
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1168 }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1169
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1170 close (OUT5);
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1171 }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1172
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1173 mkdir("StrainSpecific");
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1174 foreach my $i (keys (%specificgenes2)){
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1175
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1176 if (!$hCol_Annotated{$i}) { # si le fichier GFF n'existe pas
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1177 next;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1178 }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1179
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1180
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1181 my $strain_name = $hCol_Annotated{$i};
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1182
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1183 my $specie_name = $hSpecies{$strain_name};
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1184
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1185
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1186
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1187 open (OUT7, "> StrainSpecific/$strain_name.$specie_name.txt") or die "Cannot create file $!\n";
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1188 print OUT7 "Orthogroup\tGene\tChromosome\tStart\tEnd\tCOG categories\tNumber assigned\n";
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1189
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1190 my $refspecificgenes2 = $specificgenes2{$i};
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1191 my %subhash = %$refspecificgenes2;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1192 foreach my $gene (keys (%subhash)){
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1193 # print "$gene\n"; exit;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1194 my $cat = "unknown";
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1195 if ($Cog_of_gene{$gene}){
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1196 $cat = $Cog_of_gene{$gene};
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1197 }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1198 # if (!$Gene_position{$gene}){
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1199 # print "$gene\n coucou"; exit;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1200 # }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1201
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1202 # if (!$subhash{$gene}){
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1203 # print "$gene\n";
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1204 # }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1205 print OUT7 $subhash{$gene}."\t"."$gene\t".$Gene_position{$gene}."\t".$cat."\t".$Hash_Convert{$cat}."\n";
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1206
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1207 }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1208
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1209 close (OUT7);
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1210 }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1211
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1212
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1213 mkdir("GroupSpecific");
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1214 foreach my $i (keys (%Genes_of_OG)){
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1215 if (!$hCol_Annotated{$i}) { # si le fichier GFF n'existe pas
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1216 next;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1217 }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1218
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1219 my $strain_name = $hCol_Annotated{$i};
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1220
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1221 my $specie_name = $hSpecies{$strain_name};
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1222
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1223 open (OUT6, "> GroupSpecific/$strain_name.$specie_name.txt") or die "Cannot create file $!\n";
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1224 print OUT6 "Orthogroup\tGene\tChromosome\tStart\tEnd\tCOG categories\tNumber assigned\n";
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1225
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1226 my $refGenes_of_OG = $Genes_of_OG{$i};
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1227 my %subhash = %$refGenes_of_OG;
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1228
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1229 foreach my $orthogroup (keys (%subhash)){
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1230 if ($Hash_Specific{$orthogroup} && $Hash_Specific{$orthogroup} eq $specie_name){
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1231 my $gene = $subhash{$orthogroup};
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1232
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1233 my $cat = "unknown";
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1234 if ($Cog_of_gene{$gene}){
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1235 $cat = $Cog_of_gene{$gene};
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1236 }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1237 print OUT6 $orthogroup."\t".$subhash{$orthogroup}."\t".$Gene_position{$gene}."\t".$cat."\t".$Hash_Convert{$cat}."\n";
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1238 }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1239
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1240 }
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1241 close (OUT6);
45cc191a3290 Uploaded
mgarnier
parents:
diff changeset
1242 }