pabla23 has asked for the wisdom of the Perl Monks concerning the following question:
And in another file this:use strict; use warnings; my $mio; my $filename = '/Users/Pabli/Desktop/do_human_mapping.gmt'; my $match = 'DOID:2055'; unlink ("myoutputfilename3.txt"); open(my $file, '<', $filename) or die "open: $!"; while (<$file>){ my ($name,$id,@genes) = split /\t/; if ($id eq $match) { $mio= join("\n",@genes); print $mio."\n"; open my $out_file, '>>', 'myoutputfilename3.txt' or die "$!"; print $out_file $mio."\n"; # print sul file } }
I would like to unify this two files. The output of the first file is a list in this format:use strict; use warnings; my $mio2; my $filename = '/Users/Pabli/Desktop/do_human_mapping.gmt'; my $match = 'APOE'; unlink ("myoutputfilename4.txt"); open(my $file, '<', $filename) 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 } }
APOE
FKBP5
CRH
IL2
Infact into the second file i wrote explicit "APOE".Can someone help me in order to automate all?
Thanks a lot Paola
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Unify two files
by Laurent_R (Canon) on Nov 10, 2014 at 11:27 UTC | |
by pabla23 (Novice) on Nov 10, 2014 at 11:59 UTC | |
by poj (Abbot) on Nov 10, 2014 at 13:13 UTC | |
by pabla23 (Novice) on Nov 10, 2014 at 14:01 UTC | |
|
Re: Unify two files
by blindluke (Hermit) on Nov 10, 2014 at 09:52 UTC |