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 } } #### 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 = ) { 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 =){ my @splitted_string=split(' ',$line); foreach my $key (@splitted_string){ if (exists $hash_value{$key}){ print "$key name:$hash_value{trim($key)}"; } } } close FILE;