annotate pangenomeCogAnalysis_V1.pl @ 1:1f75641c2ee8 draft

Uploaded
author mgarnier
date Wed, 30 Jun 2021 15:43:43 +0000
parents 731fb6cb324b
children 0428ce25da81
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
1 #!/usr/bin/perl
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
2
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
3 use strict;
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
4 use warnings;
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
5
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
6 my $num_args = $#ARGV + 1;
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
7 if ($num_args != 11) {
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
8 print "Il n'y a pas le bon nombre d'arguments !\n";
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
9 exit;
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
10 }
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
11
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
12 # INPUT_
731fb6cb324b 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
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
14 my $species_file = $ARGV[1]; # association de chaque souche à son espèce (fichier tabulé également)
731fb6cb324b 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)
731fb6cb324b 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
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
17 my $annotation_GFF = $ARGV[4]; # fichiers avec les GFF
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
18 my $order_GFF = $ARGV[5];
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
19
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
20 # OUTPUT_
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
21 my $output = $ARGV[6]; # liste des espèces avec leurs orthogroupes (présence-absence)
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
22 my $output2 = $ARGV[7]; # fichier des moyennes
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
23 my $output3 = $ARGV[8]; # fichier de la liste des valeurs pour chaque catégorie de COG et pour chaque espèce
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
24 my $output4 = $ARGV[9]; # fichier avec les catégories de COG pour core-génome / génome accessoire / gènes spé
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
25 my $output5 = $ARGV[10]; # sortie qui affiche les GFF
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
26
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
27
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
28 # print "ok\n";
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
29 # exit;
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
30
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
31 my %hSpecies = (); # HASH -> key: N_Id (ex NF_AR12) ; val: nom de l'esp (ex Naegleria Fowleri)
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
32
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
33 ######################## LE SPECIES_FILE ###########################
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
34 open (S, $species_file);
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
35 while (my $line = <S>){
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
36
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
37 $line =~s/\n//g; $line =~s/\r//g;
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
38 my @sp = split('\t', $line);
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
39 # print "$line\n";
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
40 # exit;
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
41 $hSpecies{$sp[0]} = $sp[1]; # key = N_Id ; val = name
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
42
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
43 }
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
44 my $nbr = keys (%hSpecies); #compter le nombre de souches max
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
45 # = taille de la table de hash
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
46 # print "J'ai $nbr clés\n";
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
47 # exit;
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
48
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
49 close (S);
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
50
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
51 #///////////////////////////////////////////////////////////////////////////////////////////////////
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
52
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
53 ############################################ LA MATRICE ############################################
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
54
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
55 open(M, $matrix_file);
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
56
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
57 my $first_line = <M>;
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
58 $first_line =~s/\n//g; $first_line =~s/\r//g; # ne garder que la première ligne du tableau
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
59 my @samples = split(/\t/,$first_line); # mettre dans une liste (@samples) chaque intitulé de colonne = N_Id
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
60 # print "$first_line\n";
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
61 # exit;
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
62
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
63 # Le but ici est de récupérer les combinaisons associées à chaque espèce : NF, NG et NL
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
64 my %hCombination =(); # HASH -> key: N_Id ; val: combinaison
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
65
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
66 for (my $i=1; $i <= $#samples; $i++){ # on parcourt chaque colonne ($i) mais on ne regarde que le N_Id
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
67 my $header = $samples[$i]; # on récupère le N_Id dans $header (soit le nom de la colonne i)
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
68 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
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
69 $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
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
70 # print "$header\n";
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
71 # exit;
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
72 }
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
73
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
74
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
75 # foreach my $species (keys (%hCombination)){
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
76 # my $combination = $hCombination{$species};
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
77 # # print "$species $combination\n";
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
78 # }
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
79
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
80
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
81 # exit;
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
82
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
83 # orthogrp présents :
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
84 my %hCombination_prs = (); # HASH -> key: combinaison ; val: liste des orthogroupes
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
85 # orthogrp absents :
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
86 my %hCombination_abs = (); # idem
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
87
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
88
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
89
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
90 my %coregenes = (); # HASH -> key: gene ; val: orthogroupe (pour core-genome)
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
91 my %specificgenes = (); # HASH -> key: gene ; val: orthogroupe (pour gènes spécifiques)
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
92 my %accessorygenes = (); # HASH -> key: gene ; val: orthogroupe (pour génome accessoire)
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
93
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
94
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
95 while(<M>) {
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
96
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
97 my $nb_found = 0;
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
98 my @infos = split(/\t/,$_);
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
99 my $orthogroup = $infos[0]; # on récupère le nom de l'orthogroupe dans $orthogroup
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
100 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
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
101 my $combi_prs = "";
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
102 my $combi_abs = "";
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
103 my $val;
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
104 my $gene_random;
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
105
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
106 for (my $i=1; $i <= $#infos; $i++){ # on travaille par ligne puis dans chaque ligne (while(<M>)), cellule par cellule (cette boucle for)
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
107
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
108 $val = $infos[$i]; # on récupère l'information contenue dans la case $i
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
109
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
110 if ($val =~/\w/){ # s'il cette cellule contient qq chose...
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
111 $combi_prs .= "_".$i; # ...on va concaténer notre chaine $combi_prs pour que cela forme une combinaison
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
112 $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)
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
113 $gene_random=$val; # on récupère la valeur de la case (les gènes)
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
114 }
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
115
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
116 else { # si jamais il n'y a rien dans la cellule...
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
117 $combi_abs .= "_".$i; # ... on fait la même chose mais avec $combi_abs
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
118 }
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
119
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
120 }
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
121
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
122 # $hCount{$combi}++;
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
123 $hCombination_prs{$combi_prs}.=$orthogroup."\n"; # à la fin de chaque ligne, on va ajouter notre orthogroupe à la combinaison qui lui correspond
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
124 $hCombination_abs{$combi_abs}.=$orthogroup."\n";
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
125
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
126
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
127
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
128
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
129 if ($nb_found == $#infos){ # si nb_found = au nombre de souche, c'est qu'on a à faire à un core-génome
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
130 # print "$orthogroup\n";
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
131 # print "$nb_found\n=================\n";
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
132 my @list_of_genes = split (',', $first_column); # ici va séparer tous les gènes (qui se présentent comme une liste, séparés par des ',')
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
133 my $first_gene = $list_of_genes[0]; # prend la valeur du premier gène uniquement !
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
134 $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)
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
135 # foreach my $oups (@list_of_genes) {
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
136 # print "$orthogroup\n";
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
137 # print "$first_gene\n--------------------------\n";
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
138 # }
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
139
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
140 }
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
141 elsif ($nb_found == 1) { # si on a un gène spé
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
142 my @list_of_genes = split (',', $gene_random); # idem, on ne veut qu'un seul gène donc on crée la liste
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
143 my $first_gene = $list_of_genes[0]; # on ne prend que le premier
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
144 $specificgenes{$first_gene}= $orthogroup; # et pareil on crée la table de hash
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
145 }
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
146
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
147 else { # là c'est le génome accessoire, i.e tout le reste !
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
148 my @list_of_genes = split (',', $gene_random);
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
149 my $first_gene = $list_of_genes[0];
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
150 $accessorygenes{$first_gene}= $orthogroup;
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
151 }
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
152
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
153 }
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
154 # while (my ($k,$v) = each(%coregenes)) {
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
155 # print "gene=$k OG=$v\n";
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
156 # }
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
157 # exit;
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
158 # foreach my $oups (keys (%coregenes)) {
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
159 # print "$oups\n";
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
160 # }
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
161 # exit;
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
162
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
163 close (M);
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
164
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
165 open (OUT, '>', $output) or die $!;
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
166 print OUT "$annotation\n";
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
167 foreach my $species (keys (%hCombination)){ # parcours de la table de hash %hCombination (key: nom esp ; val: combi)
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
168 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
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
169 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
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
170 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
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
171
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
172 # open (OUT,">results.list.txt");
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
173
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
174 if ($ortho_presents){
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
175 print OUT "> $species - present\n";
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
176 print OUT "$ortho_presents\n";
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
177 }
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
178
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
179 if ($ortho_absents){
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
180 # open (OUT2,">$species.$combination.absents.list.txt");
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
181 print OUT "> $species - absent\n";
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
182 print OUT "$ortho_absents\n";
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
183 }
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
184
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
185 # close(OUT2);
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
186 }
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
187
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
188 close(OUT);
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
189
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
190 #//////////////////////////////////////////////////////////////////////////////////////////////////
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
191
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
192 ############################################### COG ###############################################
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
193
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
194 # STEP 1 : CORRESPONDANCE ENTRE LES DIFFERENTS FICHIERS DE COG ET L'ORDRE --------------------------------------------
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
195 my @files = split(',', $annotation); # liste des différents fichiers COG (qui se retrouvent dans le dossier Naegleria)
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
196 my @list = split(',', $order); # liste de l'ordre des souches
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
197 my ($f,$l);
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
198
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
199 my %hCorrespondance = (); #HASH -> key: un fichier COG ; val: un nom de souche (ces 2 données sont entrées en input = $annotation et $order)
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
200
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
201 # ++++++++++++ parcours de 2 listes en même temps ++++++++++++ #
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
202 foreach $f (@files){
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
203 $hCorrespondance{$f} = $list[$l++]; # on fait correspondre pour chaque fichier de COG, un nom de souche
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
204 }
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
205
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
206 # #Affichage du hash
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
207 # foreach $f (keys %hCorrespondance){
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
208 # print $f."=>".$hCorrespondance{$f}."\n"
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
209 # }
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
210
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
211 # STEP 2 : POUR CHAQUE FICHIER DE COG, FAIRE CORRESPONDRE L'ESPECE (ET NON LA SOUCHE) -------------------------------------
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
212 my %hCorresp_file_species = (); # HASH -> key: un fichier de COG ; val: une espèce
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
213 my %species_names; # HASH -> key: nom d'espèce ; val: 1
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
214
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
215 foreach my $h (keys (%hCorrespondance)){ # parcours de la table de hash {fichier COG => nom souche}
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
216 my $smpl = $hCorrespondance{$h}; # $smpl prend la valeur de la clé (donc d'un nom de souche)
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
217 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
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
218 $species_names{$espece} = 1; # on garde sous le coude nos nom d'espèce dans cette nouvelle table de hash
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
219 $hCorresp_file_species{$h} = $espece; # BUT ATTEINT : on donne pour chaque fichier de COG le nom de l'espèce qui lui correspond
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
220 }
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
221 # while (my ($k,$v) = each(%hCorresp_file_species)) {
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
222 # print "file=$k sp=$v\n";
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
223 # }
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
224 # exit;
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
225
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
226 # STEP 3 : COMPTAGE DES CATEGORIES DE COG ------------------------------------------------------------------------------
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
227 my %hCount2 = (); # HASH -> key1: catégorie de COG ; key2: espèce associée ; val: comptage
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
228
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
229 # comptage du core-genome / des gènes spé / du génome accessoire
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
230 my %hCore_Count = (); # HASH -> key: catégorie de COG ; val: comptage (ce hash ne sera utilisé que pour le core-genome)
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
231 my %hSpecific_Count = (); # HASH -> key: catégorie de COG ; val: comptage
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
232 my %hAccessory_Count = (); # HASH -> key: catégorie de COG ; val: comptage
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
233
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
234 # hash pour récupérer le gène
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
235 my %hCore_Cat = (); # HASH -> key: catégorie de COG ; val: gène
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
236 my %hAccessory_Cat = (); # HASH -> key: catégorie de COG ; val: gène
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
237 my %hSpecific_Cat = (); # HASH -> key: catégorie de COG ; val: gène
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
238
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
239 # hash pour récupérer le gène
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
240 my %hCore_Cat_Esp = (); # HASH -> key1: catégorie de COG ; key2: espèce ; val: gène
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
241 my %hAccessory_Cat_Esp = (); # HASH -> key1: catégorie de COG ; key2: espèce ; val: gène
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
242 my %hSpecific_Cat_Esp = (); # HASH -> key1: catégorie de COG ; key2: espèce ; val: gène
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
243
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
244 my %Cog_of_gene = ();
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
245
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
246 foreach my $file(@files){ # parcours de la liste des fichiers
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
247 my $esp = $hCorresp_file_species{$file}; # on récupère l'espèce pour chaque fichier de COG dans $esp
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
248 # print $esp."\n";
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
249 # exit;
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
250
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
251 my %hCount = (); # HASH -> key: catégorie de COG ; val: comptage
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
252
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
253
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
254 open (A, $file); # on va parcourir maintenant chaque fichier un à un
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
255
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
256 while (my $line2 = <A>){
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
257
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
258 $line2 =~s/\n//g; $line2 =~s/\r//g; # on procède ligne par ligne
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
259 my @Genes = split('\t', $line2);
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
260 my $gene = $Genes[0];
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
261 my $first_cat = $Genes[2];
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
262 $Cog_of_gene{$gene} = $first_cat;
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
263
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
264 for (my $j=2; $j <= $#Genes; $j++) {
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
265 my $cat = $Genes[$j]; # on récupère la ou les catégorie(s) de COG
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
266 $hCount{$cat}++; # pour la catégorie donnée, on incrémente son nb d'occurences
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
267
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
268 if ($coregenes{$gene}){ # si le $gene fait bien partie du core-genome (donc de notre table de hash %coregenes)
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
269 $hCore_Count{$cat}++; # on incrémente le hash
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
270 $hCore_Cat{$cat}=$gene; # on récupère le nom du gène
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
271 }
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
272 if ($accessorygenes{$gene}){ # s'il fait partie des gènes accessoires
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
273 $hAccessory_Count{$cat}++;
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
274 $hAccessory_Cat{$cat}=$gene;
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
275 }
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
276 if ($specificgenes{$gene}){ # s'il fait partie des gènes spécifiques
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
277 $hSpecific_Count{$cat}++;
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
278 $hSpecific_Cat{$cat}=$gene;
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
279 }
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
280 # $hCount2{$cat}{$esp}++; # TABLE DE HASH AVEC CLES=CAT DE COG + ESPECE VAL=COMPTAGE
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
281 }
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
282
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
283 }
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
284 close (A);
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
285
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
286 # print "$file $esp\n=============\n";
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
287 while (my ($k,$v) = each(%hCount)) { # parcours de la table de hash de comptage
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
288 # print "cat=$k nb=$v\n";
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
289 $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
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
290 # 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)
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
291 }
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
292
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
293 # Récupérer les gènes du core-génome
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
294 while (my ($cat_core,$gene_core) = each(%hCore_Cat)) {
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
295 $hCore_Cat_Esp{$cat_core}{$esp}=$gene_core;
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
296 }
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
297 # Récupérer les gènes du génome-accessoire
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
298 while (my ($cat_acc,$gene_acc) = each(%hAccessory_Cat)) {
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
299 $hAccessory_Cat_Esp{$cat_acc}{$esp}=$gene_acc;
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
300 }
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
301 # Récupérer les gènes spécifique
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
302 while (my ($cat_spe,$gene_spe) = each(%hSpecific_Cat)) {
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
303 $hSpecific_Cat_Esp{$cat_spe}{$esp}=$gene_spe;
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
304 }
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
305
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
306 }
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
307 # foreach my $category (sort keys (%hSpecific_Cat_Esp)) { # parcours au niveau de la 1ere clé
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
308
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
309 # foreach my $especeee (keys %{$hSpecific_Cat_Esp{$category} }) { # parcours au niveau de la 2e clé pour la $category donnée
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
310
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
311 # print "$category\t$especeee\t$hSpecific_Cat_Esp{$category}{$especeee}\n"; # on crée une sortie qui affiche en somme notre hash %hCount2
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
312 # }
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
313 # }
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
314 # exit;
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
315
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
316 # STEP 4 : AFFICHAGE DANS LE FICHIER DE SORTIE ------------------------------------------------------------------------------
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
317 open (OUT4, ">$output4") or die $!;
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
318
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
319 print OUT4 "Species"."\t"."COG categories"."\t"."Core-genome"."\t"."Accessory genome"."\t"."Specific genes"."\n";
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
320
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
321 foreach my $category (sort keys (%hCount2)){ # parcours de la table %hCount2 au niveau des catégories
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
322 foreach my $especeee (keys %{$hCount2{$category} }){ # parcours de la table %hCount2 au niveau des espèces
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
323 print OUT4 "$especeee\t$category\t"; # affichage des esp puis des cat
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
324
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
325 # if ($hCore_Cat_Esp{$category}{$especeee}) {
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
326 # print OUT4 "$hCore_Cat_Esp{$category}{$especeee}\t";
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
327 # }
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
328 my $c = 0;
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
329 if ($hCore_Count{$category}){ # si cette catégorie existe dans le core-génome
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
330 $c = ($hCore_Count{$category}/scalar keys (%coregenes))*100; # calcul du % du comptage
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
331 }
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
332 print OUT4 "$c\t"; # affichage du %
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
333
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
334 # if ($hAccessory_Cat_Esp{$category}{$especeee}) {
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
335 # print OUT4 "$hAccessory_Cat_Esp{$category}{$especeee}\t";
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
336 # }
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
337 my $acc = 0;
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
338 if ($hAccessory_Count{$category}){ # si cette catégorie existe dans le génome accessoire
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
339 $acc = ($hAccessory_Count{$category}/scalar keys (%accessorygenes))*100; # calcul du % du comptage
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
340 }
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
341 print OUT4 "$acc\t"; # affichage du %
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
342
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
343 # if ($hSpecific_Cat_Esp{$category}{$especeee}) {
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
344 # print OUT4 "$hSpecific_Cat_Esp{$category}{$especeee}\t";
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
345 # }
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
346 my $s = 0;
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
347 if ($hSpecific_Count{$category}){ # si cette catégorie existe dans les gènes spécifiques
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
348 $s = ($hSpecific_Count{$category}/scalar keys (%specificgenes))*100; # calcul du % du comptage
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
349 }
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
350 print OUT4 "$s\n"; # affichage du %
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
351 }
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
352 }
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
353 close (OUT4);
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
354
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
355 open (OUT3, ">$output3") or die $!;
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
356 foreach my $category (sort keys (%hCount2)) { # parcours au niveau de la 1ere clé
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
357
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
358 foreach my $especeee (keys %{$hCount2{$category} }) { # parcours au niveau de la 2e clé pour la $category donnée
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
359
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
360 print OUT3 "$category\t$especeee\t$hCount2{$category}{$especeee}\n"; # on crée une sortie qui affiche en somme notre hash %hCount2
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
361 }
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
362 }
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
363
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
364 close (OUT3);
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
365
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
366
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
367 open (OUT2, ">$output2") or die $!;
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
368
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
369 print OUT2 "category";
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
370 foreach my $e (sort keys (%species_names)){ # on parcours le hash d'espèces...
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
371 print OUT2 "\t".$e; #... où on récupère le nom de celles-ci
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
372 }
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
373 print OUT2 "\n";
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
374
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
375 foreach my $category (sort keys (%hCount2)) { # on parcourt de nouveau les catégories de notre hash à 2 clés
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
376 print OUT2 $category;
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
377
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
378 foreach my $especes (sort keys (%species_names)) { # on parcourt également le hash d'espèces
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
379
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
380 my $nbr = 0;
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
381 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
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
382 $nbr = $hCount2{$category}{$especes};
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
383 }
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
384 # $nbr =~s/\n//g; $nbr =~s/\r//g;
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
385
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
386
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
387 my @liste = split(',', $nbr); # vu qu'il peut y avoir plusieurs nombres on les dissocie
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
388
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
389 my $somme=0;
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
390 my $n=0;
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
391 my $moyenne=0;
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
392 #print "\nma liste de $nbr: ".join("%",@liste)."\n";
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
393 foreach my $x (@liste) { # on parcourt nos nombres
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
394 $somme=$somme+$x;
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
395 $n=$n+1;
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
396 }
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
397
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
398 if ($n>0){
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
399 $moyenne = $somme/$n; # on fait le calcul de la moyenne
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
400 }
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
401 # print "$category, $especes: $hCount2{$category}{$especes}\t";
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
402 # print "moyenne = $moyenne\n=============\n";
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
403
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
404 print OUT2 "\t".$moyenne; # fichier de sortie
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
405 }
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
406 print OUT2 "\n";
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
407 }
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
408
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
409 close (OUT2);
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
410
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
411 # foreach my $cat (keys (%hCore_Cat)){
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
412 # print OUT4 $c_gene."\t";
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
413 # }
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
414
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
415
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
416 #//////////////////////////////////////////////////////////////////////////////////////////////////
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
417
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
418 ############################################### GFF ###############################################
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
419
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
420 my @list_gff = split(',', $annotation_GFF); # liste des différents fichiers GFF (qui se retrouvent dans le dossier Annotation Maker)
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
421 my @order_gff = split(',', $order_GFF); # liste de l'ordre des souches
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
422 my ($g,$o);
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
423
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
424 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)
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
425 my %Gene_position = ();
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
426 my %Cat_genes = ();
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
427
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
428 # my %hCore_Cat = reverse (%hCore_Cat);
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
429
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
430 # ++++++++++++ parcours de 2 listes en même temps ++++++++++++ #
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
431 foreach $g (@list_gff){
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
432 $hgff_order{$g} = $order_gff[$o++]; # on fait correspondre pour chaque fichier GFF, un nom de souche
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
433 open (G, $g);
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
434 while (<G>) {
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
435 my @table_gff = split (/\t/, $_);
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
436 my $chr = $table_gff[0];
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
437 my $start = $table_gff[3];
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
438 my $end = $table_gff[4];
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
439 my $gene_name = $table_gff[8];
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
440 my $type = $table_gff[2];
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
441
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
442
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
443
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
444 if ($type && $type eq "mRNA" && $gene_name =~ /ID=([^;]+);/){
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
445 my $gene = $1;
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
446 # print $gene."\n";
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
447 # exit;
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
448 foreach my $cog (keys (%hCore_Cat)){
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
449 if ($hCore_Cat{$cog} eq $gene){
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
450 $Cat_genes{$gene}=$cog;
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
451 }
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
452 }
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
453
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
454 $Gene_position{$gene}="$chr\t$start\t$end";
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
455 }
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
456
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
457
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
458 }
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
459
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
460 close (G);
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
461 }
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
462
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
463 open (OUT5, "> $output5");
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
464 print OUT5 "Orthogroups\tGenes\tChromosomes\tStart\tEnd\tCOG categories\n";
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
465
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
466
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
467
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
468
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
469 # foreach my $gene1 (keys (%Gene_position)){
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
470 # if ($hCore_Cat{$gene1}){
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
471 # # print "$hCore_Cat{$gene1}\n";
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
472 # my $cog = $hCore_Cat{$gene1};
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
473 # $Hash_genes{$gene1}=$cog;
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
474 # }
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
475 # }
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
476 # while (my ($k,$v) = each(%Hash_genes)) {
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
477 # print "gene=$k cog=$v\n";
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
478 # }
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
479 # exit;
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
480
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
481 foreach my $gene (keys (%coregenes)){
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
482 # print "$gene\n";
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
483 my $cat = "unknown";
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
484 if ($Cog_of_gene{$gene}){
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
485 $cat = $Cog_of_gene{$gene};
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
486 }
1
1f75641c2ee8 Uploaded
mgarnier
parents: 0
diff changeset
487 print OUT5 $coregenes{$gene}."\t"."$gene\t".$Gene_position{$gene}."\t".$cat."\n";
0
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
488
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
489 }
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
490
731fb6cb324b Uploaded
mgarnier
parents:
diff changeset
491 close (OUT5);