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::SGDParser;
25 use POSIX qw(strftime);
30 # --------------------------------------------------------------------------------
31 # Parse command line and run if being run directly
35 my ($self, $ref_arg) = @_;
36 my $source_id = $ref_arg->{source_id};
37 my $species_id = $ref_arg->{species_id};
38 my $files = $ref_arg->{files};
39 my $verbose = $ref_arg->{verbose};
40 my $dbi = $ref_arg->{dbi};
41 $dbi = $self->dbi unless defined $dbi;
43 if((!defined $source_id) or (!defined $species_id) or (!defined $files) ){
44 croak
"Need to pass source_id, species_id and files as pairs";
48 my $file = @{$files}[0];
50 my $gene_source_id = $self->get_source_id_for_source_name(
"SGD_GENE", undef, $dbi);
51 #my $transcript_source_id = $self->get_source_id_for_source_name("SGD_TRANSCRIPT");
52 my $translation_source_id = $self->get_source_id_for_source_name(
"SGD_TRANSLATION", undef, $dbi);
54 my $sgd_io = $self->get_filehandle($file);
56 if ( !defined $sgd_io ) {
57 print STDERR
"ERROR: Could not open $file\n";
58 return 1; # 1 is an error
64 while ( $_ = $sgd_io->getline() ) {
68 if ($_ =~ /^([^\t]+)\t([^\t]+)\t([^\t]*)\t([^\t]*)\t([^\t]*)\t([^\t]*)\t[^\t]+\t[^\t]*\t[^\t]+\t[^\t]+\t[^\t]+\t[^\t]+\t[^\t]*\t[^\t]+\t[^\t]+\t([^\t]*)$/) {
69 my ($sgd_id, $biotype, $status, $orf_name, $locus_name, $alias_name, $desc) = ($1,$2,$3,$4,$5,$6,$7);
71 # parse the lines corresponding to the gene entries
72 # and filter out lines corresponding to the CDS for example
74 if ($biotype =~ /ORF|.+RNA|transposable_element_gene|pseudogene/) {
77 #print STDERR "parsing line for biotype, $biotype\n";
78 #print STDERR "sgd_id, biotype, status, orf_name, locus_name, alias_name, $sgd_id, $biotype, $status, $orf_name, $locus_name, $alias_name\n";
79 #print STDERR "desc: $desc\n";
82 if (!defined $locus_name || ($locus_name eq
"")) {
84 if (!defined $orf_name || ($orf_name eq
"")) {
85 print STDERR
"can't assign the orf_name as the locus_name!\n";
89 #print STDERR "assigning the orf_name as the locus_name(ie the gene_name)\n";
91 $locus_name = $orf_name;
95 my (@syn) = split(/\|/,$alias_name);
97 my $gene_xref_id = $self->add_xref({ acc => $sgd_id,
100 source_id => $gene_source_id,
101 species_id => $species_id,
103 info_type =>
"DIRECT"} );
104 $self->add_direct_xref($gene_xref_id, $orf_name,
"Gene",
"DIRECT", $dbi);
106 my $translation_xref_id = $self->add_xref({ acc => $sgd_id,
107 label => $locus_name,
109 source_id => $translation_source_id,
110 species_id => $species_id,
112 info_type =>
"DIRECT"} );
113 $self->add_direct_xref($translation_xref_id, $orf_name,
"Translation",
"DIRECT", $dbi);
117 foreach my $synonym (@syn){
119 # print STDERR "adding synonym, $synonym\n";
121 $self->add_to_syn($sgd_id, $gene_source_id, $synonym, $species_id, $dbi);
128 #print STDERR "filtering biotype, $biotype\n";
134 print STDERR
"failed to parse line, $_\n\n";
141 print $xref_count.
" SGD Xrefs added with $syn_count synonyms\n" if($verbose);
142 return 0; #successful