Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??
Hi guys, this is similar to a previous post i made, but a completely different question, so please offer me your guidance. Thanks!

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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others examining the Monastery: (6)
    As of 2014-12-28 16:19 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      Is guessing a good strategy for surviving in the IT business?





      Results (182 votes), past polls