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::CCDSParser;
27 # Parse file of CCDS records and assign direct xrefs
28 # All assumed to be linked to transcripts
29 # The same CCDS may be linked to more than one transcript, but need to only
30 # add the xref once, so check if it already exists before adding it.
34 my ($self, $ref_arg) = @_;
35 my $source_id = $ref_arg->{source_id};
36 my $species_id = $ref_arg->{species_id};
37 my $file = $ref_arg->{file};
38 my $verbose = $ref_arg->{verbose};
39 my $db = $ref_arg->{dba};
40 my $dbi = $ref_arg->{dbi};
41 $dbi = $self->
dbi unless defined $dbi;
43 if((!defined $source_id) or (!defined $species_id) or (!defined $file) ){
44 croak
"Need to pass source_id, species_id and file as pairs";
54 if($file =~ /host[=][>](\S+?)[,]/){
57 if($file =~ /port[=][>](\S+?)[,]/){
60 if($file =~ /dbname[=][>](\S+?)[,]/){
63 if($file =~ /pass[=][>](\S+?)[,]/){
74 $dbi2 = $ccds_db->dbi();
75 } elsif (defined $db) {
83 SELECT t.stable_id, x.dbprimary_acc
84 FROM xref x, object_xref ox,
transcript t, external_db e
85 WHERE x.xref_id=ox.xref_id AND
86 ox.ensembl_object_type =
"Transcript" AND
87 ox.ensembl_id = t.transcript_id AND
88 e.external_db_id = x.external_db_id AND
89 e.db_name like
"Ens\_%\_transcript"
94 my $sth = $dbi2->prepare($sql) or die
"Could not prepare sql $sql\n";
95 $sth->execute() or die
"Could not execute $sql\n";
98 my ($stable_id, $display_label);
99 $sth->bind_columns( \$display_label,\$stable_id);
100 while ( $sth->fetch ) {
102 my ($acc, $version) = split (/\./,$display_label);
105 if (!defined($seen{$display_label})) {
106 $xref_id = $self->add_xref({ acc => $acc,
108 label => $display_label,
109 source_id => $source_id,
110 species_id => $species_id,
112 info_type =>
"DIRECT"} );
114 $seen{$display_label} = $xref_id;
117 $xref_id = $seen{$display_label};
120 $self->add_direct_xref($xref_id, $stable_id,
"Transcript",
"", $dbi);
124 print
"Parsed CCDS identifiers from $file, added $xref_count xrefs and $direct_count direct_xrefs\n" if($verbose);