ensembl-hive  2.7.0
WormbaseCElegansRefSeqGPFFParser.pm
Go to the documentation of this file.
1 =head1 LICENSE
2 
3 See the NOTICE file distributed with this work for additional information
4 regarding copyright ownership.
5 
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
9 
10  http://www.apache.org/licenses/LICENSE-2.0
11 
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.
17 
18 =cut
19 
20 package XrefParser::WormbaseCElegansRefSeqGPFFParser;
21 use strict;
22 use warnings;
24 my $SOURCE_IDS;
25 my $ACCESSION_FROM_ENTRY_PATTERN;
26 sub run {
27  my ($self, $arg_ref) = @_;
28  my $type = $self->type_from_file(@{$arg_ref->{files}});
29  if($type eq 'peptide'){
30  $SOURCE_IDS = [ $self->get_source_id_for_source_name('protein_id') ];
31  $ACCESSION_FROM_ENTRY_PATTERN = qr/This record has been curated by WormBase. The\s+reference sequence is identical to (.*?)\./;
32  } elsif ($type eq 'dna'){
33  $SOURCE_IDS = [
34  $self->get_source_id_for_source_name('wormbase_cds'),
35  $self->get_source_id_for_source_name('wormbase_transcript'),
36  ];
37  $ACCESSION_FROM_ENTRY_PATTERN = qr/standard_name="(.*?)"/;
38  }
39  die %$arg_ref unless @$SOURCE_IDS;
40  return $self->SUPER::run($arg_ref);
41 }
42 sub upload_xref_object_graphs {
43  my ($self, $xrefs, $dbi) = @_;
44  my @adapted_xrefs;
45  for my $xref ( @$xrefs) {
46  push @adapted_xrefs, $self->swap_dependency($SOURCE_IDS, $dbi, $xref, @$SOURCE_IDS);
47  }
48  return $self->SUPER::upload_xref_object_graphs(\@adapted_xrefs, $dbi);
49 }
50 
51 sub xref_from_record {
52  my ($self, $entry, @args) = @_;
53  return &modify_xref_with_dependent(
54  $SOURCE_IDS, $entry,
55  $self->SUPER::xref_from_record($entry, @args),
56  $ACCESSION_FROM_ENTRY_PATTERN,
57  );
58 }
59 
60 sub modify_xref_with_dependent {
61  my ($source_ids, $entry, $xref, $get_accession_pattern) = @_;
62  return unless $xref;
63  my ($accession) = $entry =~ $get_accession_pattern;
64  return unless $accession;
65  $xref->{DEPENDENT_XREFS} //= [];
66  push @{$xref->{DEPENDENT_XREFS}}, map {{ACCESSION => $accession, SOURCE_ID=>$_}} @$source_ids;
67  return $xref;
68 }
69 1;
map
public map()
XrefParser::WormbaseCElegansBase
Definition: WormbaseCElegansBase.pm:2
XrefParser::RefSeqGPFFParser
Definition: RefSeqGPFFParser.pm:4
run
public run()