Good morning guys, i have this problem: i've two different script. One of this is the following

use strict; use warnings; my ($mio, $mio2); my @array_with_all_fields=(); my $match = 'DOID:2055'; unlink ("myoutputfilename6.txt"); unlink ("myoutputfilename7.txt"); open(my $file, '<', 'do_human_mapping.gmt') or die "open: $!"; open my $out_file3, '>', 'myoutputfilename6.txt' or die "$!"; open my $out_file4, '>', 'myoutputfilename7.txt' or die "$!"; while (<$file>){ my ($name,$id,@genes) = split /\t/; if ($id eq $match) { $mio= join("\n",@genes); print $mio."\n"; print $out_file3 $mio."\n"; # print on file } if (grep/^$match$/, @genes){ $mio2=$id; print $mio2."\n"; print $out_file4 $mio2."\n"; # print on file } }

The output of this script is:

APOE

FKBP5

CRH

IL2

The second script is the following:

use strict; use warnings; sub trim { my $s=shift; $s=~ s/^\s+$//g; return $s }; my $mio2; my $match = 'APOE'; unlink ("myoutputfilename4.txt"); open(my $file, '<', 'do_human_mapping.gmt') or die "open: $!"; while (<$file>){ my ($name,$id,@genes) = split /\t/; if (grep/^$match$/, @genes){ $mio2=$id; #print $mio2."\n"; open my $out_file, '>>', 'myoutputfilename4.txt' or die "$!"; print $out_file $mio2."\n"; # print sul file } } open (FILE2, 'HumanDO.obo'); my %hash_value = (); my $Key=''; my $Val=''; while (my $line = <FILE2>) { if ($line=~/^id:\s/) { my @splitted_string=split(' ',$line); $Key=$splitted_string[1]; } if ($line=~/^name:\s/) { my @splitted_string=split(':',$line); $Val=$splitted_string[1]; } if ( defined $Key and defined $Val){ $hash_value{trim($Key)}=$Val; $Key=undef; $Val=undef; } } close FILE2; open(FILE,'myoutputfilename4.txt'); while ( my $line =<FILE>){ my @splitted_string=split(' ',$line); foreach my $key (@splitted_string){ if (exists $hash_value{$key}){ print "$key name:$hash_value{trim($key)}"; } } } close FILE;

the output of this script is FOR ONLY "APOE":

DOID:2055

DOID:3453

DOID:4532

I want that the second script takes in input the list from first script and print out for EACH name (APOE, FKB5, CRH,...) the associated "DOID". Every name has more than one "DOID".

Thanks for help Paola


In reply to list in input by pabla23

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!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • 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, details, 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, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            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.