This is the code I am currently working on now.
#!/usr/bin/perl use Modern::Perl; use File::Slurp qw/read_file write_file/; my $uniprot = 'D:ARP\\Downloads\\uniprot-ACN'; my $activin = 'D:ARP\\Downloads\\Activator-Pfam.txt'; my $antioxin = 'D:ARP\\Downloads\\AntiOxidant-PFAM.txt'; my $toxinin= 'D:ARP\\Downloads\\Toxin-PFAM.txt'; my $activout = 'D:ARP\\Downloads\\ActivACNPF.txt'; my $antioxout= 'D:ARP\\Downloads\\AntioxACNPF.txt'; my $toxinout= 'D:ARP\\Downloads\\ToxinACNPF.txt'; my @activline; my @antioxline; my @toxinline; my %activ = map {s/\.\d+//g; /(.+)\s+\|\s+(.+)/ and $1 => $2 } grep / +\|\s+\S+/, read_file $activin; my %antiox = map { s/\.\d+//g; /(.+)\s+\|\s+(.+)/ and $1=>$2; } grep/\ +|\s+\S+/,read_file $antioxin; my %toxin = map { s/\.\d+//g; /(.+)\s+\|\s+(.+)/ and $1=>$2; } grep/\ +|\s+\S+/,read_file $toxinin; for ( read_file $uniprot ) { next unless /(.{6})\s+.+=([^\s]+)/; push @activline, "$1 | $2 | $activ{$1} \n" if $activ{$1}; push @antioxline, "$1 | $2 | $antiox{$1} \n" if $antiox{$1}; push @toxinline, "$1 | $2 | $toxin{$1} \n" if $toxin{$1}; } print @activline; write_file $activout, @activline; write_file $antioxout, @antioxline; write_file $toxinout, @toxinline;
This is a sample of D:ARP\\Downloads\\ActivACNPF.txt', 'D:ARP\\Downloads\\AntioxACNPF.txt' and 'D:ARP\\Downloads\\ToxinACNPF.txt' They have the same format.
Q6GZX4 | PF04947.9 Q96355 | PF01486.12 PF00319.13 Q96356 | PF01486.12 PF00319.13 Q39371 | PF01486.12 PF00319.13 Q84BZ4 | PF12833.2 Q6W4T3 | PF00501.23 PF00668.15 PF00550.20 B4YPW6 | PF01486.12 PF00319.13 Q8GTF5 | PF01486.12 PF00319.13
What I want to do is to use the 6 characters to the left side of the database (eg. Q96355), and use them in the database below to find the gene name (eg. Name=smf1; ORFNames=SPBC3E7.14, SPBC4F6.01)
O59734 | Name=smf1; ORFNames=SPBC3E7.14, SPBC4F6.01 Q97W02 | Name=dbh; Synonyms=dpo4; OrderedLocusNames=SSO2448 B0JTM2 | Name=trpC; OrderedLocusNames=MAE_45030 Q0WVE9; Q5XF02; Q9ZVN7 | OrderedLocusNames=At1g05030; ORFNames=T7A14.1 +0 Q15X31 | Name=rraB; OrderedLocusNames=Patl_1031 Q66640 | Name=36 Q9F2S0 | Name=hemL; OrderedLocusNames=SCO4469; ORFNames=SCD65.12 A9R5H1 | Name=dctA; OrderedLocusNames=YpAngola_A4067 Q7N3W0 | Name=rnt; OrderedLocusNames=plu2603 Q6GNW0 | Name=lrrfip2 Q4L4T4 | OrderedLocusNames=SH2032 B7I359 | Name=rplL; OrderedLocusNames=AB57_0368 B2HII2 | Name=leuD; OrderedLocusNames=MMAR_1727
However, when I try my code, I don't get all of the data I need. (I think perhaps it's a problem with the regex?) So I will need some assistance from you almighty ones on this matter. Thanks!
In reply to Extraction help. by invaderzard
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |