3 See the NOTICE file distributed with
this work
for additional information
4 regarding copyright ownership.
6 Licensed under the Apache License, Version 2.0 (the
"License");
7 you may not use
this file except in compliance with the License.
8 You may obtain a copy of the License at
12 Unless required by applicable law or agreed to in writing, software
13 distributed under the License is distributed on an
"AS IS" BASIS,
14 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 See the License
for the specific language governing permissions and
16 limitations under the License.
20 package XrefParser::DirectParser;
28 # This parser will read Direct Xrefs from a simple tab-delimited file.
29 # The columns of the file should be the following:
33 # 3) Type (one of 'transcript', 'gene', or 'translation',
34 # will default to 'gene')
35 # 4) Display label (will default to the Accession ID in column 1)
36 # 5) Description (will default to the empty string)
37 # 6) Version (will default to '1')
39 # Columns 1 and 2 are obligatory.
42 my ($self, $ref_arg) = @_;
43 my $source_id = $ref_arg->{source_id};
44 my $species_id = $ref_arg->{species_id};
45 my $filename = $ref_arg->{file};
46 my $verbose = $ref_arg->{verbose};
48 if((!defined $source_id) or (!defined $species_id) or (!defined $filename) ){
49 croak
"Need to pass source_id, species_id and file as pairs";
54 my $file_io = $self->get_filehandle($filename);
55 if ( !defined($file_io) ) {
61 printf( STDERR
"source = %d\t species = %d\n",
62 $source_id, $species_id );
64 while ( defined( my $line = $file_io->getline() ) ) {
67 my ( $accession, $ensembl_id, $type, $label, $description, $version )
68 = split( /\t/, $line );
70 if ( !defined($accession) || !defined($ensembl_id) ) {
71 print {*STDERR}
"Line $parsed_count contains has less than two columns.\n";
72 print {*STDERR} (
"The parsing failed\n");
77 $label ||= $accession;
84 $self->get_xref( $accession, $source_id, $species_id );
86 if ( !defined($xref_id) || $xref_id eq
'' ) {
88 $self->add_xref({ acc => $accession,
92 source_id => $source_id,
93 species_id => $species_id,
94 info_type =>
"DIRECT"} );
96 $self->add_direct_xref( $xref_id, $ensembl_id,
98 } ## end
while ( defined( my $line...
100 printf(
"%d direct xrefs succesfully parsed\n", $parsed_count )
if($verbose);
104 print
"Done\n" if($verbose);;