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.
26 This parser will read and create dependent xrefs from a simple
35 files => [
"/nfs/production/flicek/wormbase/parasite/data/synonyms/strongyloides_stercoralis_prjeb528/curated_synonyms.tsv" ],
40 package XrefParser::WormBaseCuratedSynonymsParser;
53 my ($self, $ref_arg) = @_;
54 my $source_id = $ref_arg->{source_id};
55 my $species_id = $ref_arg->{species_id};
56 my $files = $ref_arg->{files};
58 if((!defined $source_id) or (!defined $species_id) or (!defined $files)){
59 croak
"Need to pass source_id, species_id and files as pairs";
63 my $sth = $self->dbi()->prepare(
"SELECT xref_id FROM xref WHERE accession=? AND source_id=? AND species_id=$species_id");
64 $src_ids{curated_gene_synonyms} = $self->get_source_id_for_source_name(
"curated_gene_synonyms");
65 my $data = $self->get_data(@$files);
66 for my $gene_id (keys %$data){
67 for my $synonym (@{$data->{$gene_id}->{synonyms}}) {
68 $self->add_xref_and_direct_xref(
69 $sth, $species_id,
"gene", $src_ids{curated_gene_synonyms},
70 $gene_id, $synonym->{synonym_id}
77 my ($self, $file) = @_;
78 my $pep_io = $self->get_filehandle($file) or croak
"Could not open: $file";
82 while ( $_ = $pep_io->getline() ) {
85 my ($stabid, $synonym) = split(/\t/, $_);
88 $data->{$stabid}->{synonyms}
89 push @{$data->{$stabid}->{synonyms}}, {
90 synonym_id => $synonym
97 sub add_xref_and_direct_xref {
98 my ($self, $sth, $species_id, $object_type, $source_id, $object_id, $label, $primary_id) = @_;
100 return unless $label;
101 $sth->execute($primary_id, $source_id);
102 $self->add_direct_xref(
103 ($sth->fetchrow_array())[0]
107 source_id => $source_id,
108 species_id => $species_id,
109 info_type =>
"DIRECT"
111 , $primary_id, $object_type,
"");