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 Please email comments or questions to the
public Ensembl
21 developers list at <http:
23 Questions may also be sent to the Ensembl help desk at
32 A parser
class to parse the VGNC source.
33 VGNC is the official naming source for some vertebrates species
53 date_approved_reserved
62 Only columns listed in
@required_columns are mandatory.
71 files => [
'VGNC/vgnc_gene_set_All.txt.gz'],
76 package XrefParser::VGNCParser;
89 Exceptions :
throws on all processing errors
90 Caller : ParseSource in the xref pipeline
94 my ($self, $ref_arg) = @_;
96 my $source_id = $ref_arg->{source_id};
97 my $species_id = $ref_arg->{species_id};
98 my $files = $ref_arg->{files};
99 my $verbose = $ref_arg->{verbose}
100 my $dbi = $ref_arg->{dbi}
103 if ( (!defined $source_id) || (!defined $species_id) || (!defined $files) ) {
104 confess
"Need to pass source_id, species_id and files as pairs";
107 my $file = @{$files}[0];
111 my $file_io = $self->get_filehandle($file);
113 if ( !defined $file_io ) {
114 confess
"Can't open VGNC file '$file'\n";
117 my $source_name = $self->get_source_name_for_source_id($source_id, $dbi);
119 # Create a hash of all valid taxon_ids for this species
120 my %species2tax = $self->species_id2taxonomy($dbi);
121 push @{$species2tax{$species_id}}, $species_id;
122 my @tax_ids = @{$species2tax{$species_id}};
123 my %taxonomy2species_id =
map{ $_=>$species_id } @tax_ids;
125 my $input_file = Text::CSV->new({
129 }) or confess
"Cannot use file '$file': ".Text::CSV->error_diag();
131 # header must contain these columns
132 my
@required_columns = qw(
143 my @columns = @{ $input_file->getline( $file_io ) };
145 # die if some required_column is not in columns
146 foreach my $colname (@required_columns) {
147 if ( !grep { /$colname/xms } @columns ) {
148 confess
"Can't find required column '$colname' in VGNC file '$file'\n";
152 $input_file->column_names( @columns );
154 while ( my $data = $input_file->getline_hr( $file_io ) ) {
156 # skip data for other species
157 next
if ( !exists $taxonomy2species_id{$data->{
'taxon_id'}} );
159 if ( $data->{
'ensembl_gene_id'} ) { # Ensembl direct xref
160 $self->add_to_direct_xrefs({
161 stable_id => $data->{
'ensembl_gene_id'},
163 acc => $data->{
'vgnc_id'},
164 label => $data->{
'symbol'},
165 desc => $data->{
'name'},
167 source_id => $source_id,
168 species_id => $species_id
171 $self->add_synonyms_for_hgnc({
172 source_id => $source_id,
173 name => $data->{
'vgnc_id'},
174 species_id => $species_id,
176 dead => $data->{
'alias_symbol'},
177 alias => $data->{
'prev_symbol'}
185 $input_file->eof or confess
"Error parsing file '$file': " . $input_file->error_diag();
189 print
"Loaded a total of $count VGNC xrefs\n";
192 return 0; # successful