my ($self, $args) = @_;
my $source_id = $args->{'source_id'};
my $species_id = $args->{'species_id'};
my $files = $args->{'files'};
my $release_file = $args->{'rel_file'};
my $verbose = $args->{'verbose'};
my $file = ref $files eq 'ARRAY' ? shift @$files : '';
if ( !$file ) {
printf STDERR "%s called without a 'files' argument\n%s",
__PACKAGE__, Dumper($args);
return 1; # error
}
my $p = Text::RecordParser::Tab->new( $file );
my $direct_xref_count = 0;
while ( my $rec = $p->fetchrow_hashref ) {
my $gene = $rec->{'gene_name'} or next;
if ( my $ec = $rec->{'ec'} ) {
my $ec_xref_id = $self->add_xref({
source_id => $source_id,
species_id => $species_id,
acc => $ec,
label => '',
desc => '',
info_type => 'DIRECT',
});
$self->add_direct_xref( $ec_xref_id, $gene, 'Gene', 'DIRECT' );
$direct_xref_count++;
}
if ( my $pathway_id = $rec->{'pathway_id'} ) {
my $pathway_xref_id = $self->add_xref({
source_id => $source_id,
species_id => $species_id,
acc => $pathway_id,
label => $rec->{'pathway_name'},
desc => '',
info_type => 'DIRECT'
});
$self->add_direct_xref( $pathway_xref_id, $gene, 'Gene', 'DIRECT' );
$direct_xref_count++;
}
}
printf "Parsed pathway Ids from file '%s,' added %s direct_xrefs\n",
$file, $direct_xref_count;
return 0; # success
}