Bonjour,
J'ai un problème de références.
J'ai deux Tableaux contenant 4 types d'informations.
1) nom de l'enzyme
2) site de restriction
3) nombre de fois présent
4) localisations
J'aimerais comparer dans ces deux tableaux, les enzymes communes mais étant présentes un nombre différent de fois.
Mes informations sont stockées dans deux fichiers textes sous la forme
Citation:
Enzyme Recognition frequency Positions
____________________________________________________
AatII G_ACGT'C 1 523
AccI GT'mk_AC 1 523
Acc65I G'GTAC_C 1 1391
Je récupère bien ces 4 "champs" dans des variables $1, $2, $3 et $4.
Ensuite, je ne sais pas que structure donner à mes deux tableaux. Qu'est-ce qui serait le plus simple pour ensuite pouvoir comparer les "champs" Enzyme et Frequency?
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113
|
#!/usr/bin/perl
#-------------------------------- ComparaisonRestrictions.pl ------------------------------------#
# Ce programme prend en entrée deux fichiers textes contenant les informations de cartes #
# de restriction générées par BioEdit et donne les enzymes coupant un nombre différent #
# de fois ces deux séquences #
#------------------------------------------------------------------------------------------------#
=h
FICHIER D ENTREE
Restriction table:
Enzyme Recognition frequency Positions
__________________________________________________________________________
AatII G_ACGT'C 1 523
AccI GT'mk_AC 1 523
Acc65I G'GTAC_C 1 1391
AflIII A'CryG_T 2 882, 1021
AleI CACnn'nnGTG 1 862
AlwI GGATCnnnn'n_ 2 239, 451
ApoI r'AATT_y 1 623
AvaI C'yCGr_G 1 1687
BaeI ACnnnnGTAyCnnnnnnn_nnnnn' 1 320
BaeI GrTACnnnnGTnnnnnnnnnn_nnnnn' 1 287
BanI G'GyrC_C 2 838, 1391
BanII G_rGCy'C 1 1150
BbsI GAAGACnn'nnnn_ 4 334, 1129, 1497, 1525
BbvI GCAGCnnnnnnnn'nnnn_ 9 435, 715, 894, 962, 993, 1123
1308, 1529, 1639
BceAI ACGGCnnnnnnnnnnnn'nn_ 1 947
BfrBI ATG'CAT 1 354
=cut
use strict;
use warnings;
use FileHandle;
use Data::Dumper;
my $InFile1 = 'P:/Perl/scripts/Files/Restriction1.txt';
my $InFile2 = 'P:/Perl/scripts/Files/Restriction2.txt';
# my $Outfile = FileHandle->new (">P:/Perl/scripts/Files/ComparaisonRestrictions.txt");
# Ouverture des fichiers
#------------------------
open (FileTxt1,"$InFile1") or die "Can't open file1\n";
open (FileTxt2,"$InFile2") or die "Can't open file2\n";
# Lecture des fichiers de restriction
#--------------------------------------
my $Ligne;
my %Hash1;
my $ref_Hash1 = \%Hash1;
my %Hash2;
my $ref_Hash2 = \%Hash2;
while ($Ligne =<FileTxt1>)
{
if($Ligne =~ /^([\w]+)\s+([\w\']+)\s+(\d{1,2})\s+([\,\d\s]+)$/)
{
$ref_Hash1->{$1}=[$2, $3, $4];
#print Dumper($ref_Hash1)."\n\n";
}
}
while ($Ligne =<FileTxt2>)
{
if($Ligne =~ /^([\w]+)\s+([\w\']+)\s+(\d{1,2})\s+([\,\d\s]+)$/)
{
$ref_Hash2->{$1}=[$2, $3, $4];
}
}
#print Dumper($ref_Hash1)."\n\n";
foreach my $cle (%$ref_Hash1)
{
print "Cle = ".$cle."\n";
}
close; |
Mes fichiers textes:
Citation:
Enzyme Recognition frequency Positions
__________________________________________________________________________
AccI GT'mk_AC 3 211, 487, 1618
AfeI AGC'GCT 1 305
AflII C'TTAA_G 1 345
AflIII A'CryG_T 2 459, 826
AloI GAACnnnnnnTCCnnnnnnn_nnnnn' 1 968
AloI GGAnnnnnnGTTCnnnnnnn_nnnnn' 1 936
AlwI GGATCnnnn'n_ 1 34
ApoI r'AATT_y 1 55
BaeI ACnnnnGTAyCnnnnnnn_nnnnn' 1 1057
BaeI GrTACnnnnGTnnnnnnnnnn_nnnnn' 1 1024
BanII G_rGCy'C 2 1126, 1420
BbsI GAAGACnn'nnnn_ 1 316
BbvI GCAGCnnnnnnnn'nnnn_ 7 988, 1281, 1284, 1435, 1438, 1529
1557
BceAI ACGGCnnnnnnnnnnnn'nn_ 2 1359, 1420
BfrBI ATG'CAT 1 962
BglI GCCn_nnn'nGGC 1 384
BglII A'GATC_T 1 686
BmrI ACTGGGnnnn_n' 1 644
BpuEI CTTGAGnnnnnnnnnnnnnn_nn' 2 998, 1428
BsaI GGTCTCn'nnnn_ 2 15, 1593
BsaAI yAC'GTr 4 460, 663, 807, 1036
BsaBI GATnn'nnATC 1 912
BsaHI Gr'CG_yC 2 454, 951
BsaJI C'CnnG_G 5 674, 920, 1204, 1412, 1691
et
Citation:
Enzyme Recognition frequency Positions
__________________________________________________________________________
AatII G_ACGT'C 1 523
AccI GT'mk_AC 1 523
Acc65I G'GTAC_C 1 1391
AflIII A'CryG_T 2 882, 1021
AleI CACnn'nnGTG 1 862
AlwI GGATCnnnn'n_ 2 239, 451
ApoI r'AATT_y 1 623
AvaI C'yCGr_G 1 1687
BaeI ACnnnnGTAyCnnnnnnn_nnnnn' 1 320
BaeI GrTACnnnnGTnnnnnnnnnn_nnnnn' 1 287
BanI G'GyrC_C 2 838, 1391
BanII G_rGCy'C 1 1150
BbsI GAAGACnn'nnnn_ 4 334, 1129, 1497, 1525
BbvI GCAGCnnnnnnnn'nnnn_ 9 435, 715, 894, 962, 993, 1123
1308, 1529, 1639
BceAI ACGGCnnnnnnnnnnnn'nn_ 1 947
BfrBI ATG'CAT 1 354
BglI GCCn_nnn'nGGC 1 1245
BmgBI CAC'GTC 1 1613
BmrI ACTGGGnnnn_n' 3 668, 1044, 1390
BplI GAGnnnnnCTCnnnnnnnn_nnnnn' 4 1026, 1058, 1424, 1456
BpmI CTGGAGnnnnnnnnnnnnnn_nn' 2 652, 1464
Bpu10I CC'TnA_GC 2 1249, 1555
BsaI GGTCTCn'nnnn_ 3 663, 730, 1046
BsaAI yAC'GTr 2 864, 1584
BsaHI Gr'CG_yC 2 520, 1683
BsaJI C'CnnG_G 3 790, 1546, 1688
BsaXI ACnnnnnCTCCnnnnnnn_nnn' 1 1422
Voici ma structure actuelle:
Citation:
$VAR1 = {
'BsrI' => [
'ACTG_Gn\'',
'6',
'591, 663, 1050, 1097, 1218, 1396
'
],
'TspGWI' => [
'ACGGAnnnnnnnnn_nn\'',
'6',
'137, 177, 237, 779, 1343, 1563
'
],
'Hpy8I' => [
'GTn\'nAC',
'4',
'77, 83, 524, 1358
'
],
'FauI' => [
'CCCGCnnnn\'nn_',
'2',
'275, 279
'
],
'PpuMI' => [
'rG\'GwC_Cy',
'1',
'437
'
]
};
par exemple pour
Citation:
'AatII' => [
'G_ACGT\'C',
'1',
'523
'
]
Il faudra donc que je compare la clé "AatII' " et le nombre de sites "1" pour mes deux tableaux.
Est-ce une bonne façon de procéder?
Merci beaucoup,
Jasmine,