in reply to Text manipulation on a file with multiple entries, obo format

ok

I don't quite get your problem but as far as i understood you want soimething like this:

use strict; use Data::Dumper; open(IN, "<", "in.obo") || die "$!"; my %hash; my $term; while(<IN>){ chomp; if(/^id\:\s+(.*)/){ $term = $1; }elsif(/^is\_a\:\s+.*?\s+\!\s+(.*)/){ push(@{$hash{$term}},$1); } } close IN; print Dumper(\%hash);
Did I get it right?

PS: code not tested

Replies are listed 'Best First'.
Re^2: Text manipulation on a file with multiple entries, obo format
by Sakti (Novice) on Oct 01, 2015 at 21:39 UTC
    Thank you, I will test this code as well as the CPAN module, which seems like the easiest way to do it. Best!