my ($self, $ref_arg) = @_;
my $source_id = $ref_arg->{source_id};
my $species_id = $ref_arg->{species_id};
my $files = $ref_arg->{files};
my $verbose = $ref_arg->{verbose}
if ( (!defined $source_id) || (!defined $species_id) || (!defined $files) ) {
confess "Need to pass source_id, species_id and files as pairs";
}
my $file = @{$files}[0];
#e.g.
#ZDB-GENE-050102-6 WITHDRAWN:zgc:92147 WITHDRAWN:zgc:92147 0
#ZDB-GENE-060824-3 apobec1 complementation factor a1cf 0
#ZDB-GENE-090212-1 alpha-2-macroglobulin-like a2ml 15 ZDB-PUB-030703-1
my $count = 0;
my $withdrawn = 0;
my $file_io = $self->get_filehandle($file);
if ( !defined $file_io ) {
confess "Can't open ZFINDesc file '$file'\n";
}
my $input_file = Text::CSV->new({
sep_char => "\t",
empty_is_undef => 1,
binary => 1
}) or confess "Cannot use file '$file': " . Text::CSV->error_diag();
# 2 extra columns are ignored
$input_file->column_names( [ 'zfin', 'desc', 'label'] );
while ( my $data = $input_file->getline_hr( $file_io ) ) {
# skip if WITHDRAWN: this precedes both desc and label
if ( $data->{'label'} =~ /\A WITHDRAWN:/xms ) {
$withdrawn++;
}
else {
$self->add_xref({
acc => $data->{'zfin'},
label => $data->{'label'},
desc => $data->{'desc'},
source_id => $source_id,
species_id => $species_id,
info_type => "MISC"
});
$count++;
}
}
$input_file->eof or confess "Error parsing file $file: " . $input_file->error_diag();
$file_io->close();
if($verbose){
print "$count ZFINDesc xrefs added, $withdrawn withdrawn entries ignored\n";
}
return 0;
}