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 A parser
class to parse the MGI (official) source,
27 creating a DIRECT xref between MGI
accession and ensembl mouse gene stable id ENSMUSG*
29 -species = mus_musculus
33 -columns = [
accession symbol name position chrom ens_gene_stableid] ##ignore other columns
41 files => [
"MRK_ENSEMBL.rpt"],
45 package XrefParser::MGIParser;
55 Arg [1] : HashRef standard list of arguments from ParseSource
56 Example : $mgi_parser->run({ ... });
57 Description: Runs the MGIParser
58 Return type: 0 on success
59 Exceptions :
throws on all processing errors
60 Caller : ParseSource in the xref pipeline
65 my ( $self, $ref_arg ) = @_;
66 my $source_id = $ref_arg->{source_id};
67 my $species_id = $ref_arg->{species_id};
68 my $files = $ref_arg->{files};
69 my $verbose = $ref_arg->{verbose}
70 my $dbi = $ref_arg->{dbi}
72 if ( ( !defined $source_id )
73 or ( !defined $species_id )
74 or ( !defined $files ) )
76 confess
'Need to pass source_id, species_id and files as pairs';
79 my $file = @{$files}[0];
81 my $file_io = $self->get_filehandle($file);
82 if ( !defined $file_io ) {
83 confess
"Could not open $file\n";
86 #synonyms; move this to SynonymAdaptor?!
87 my $syn_hash = $self->get_ext_synonyms(
'MGI', $dbi );
90 my $input_file = Text::CSV->new(
95 allow_loose_quotes => 1,
97 ) or confess
"Cannot use file $file: " . Text::CSV->error_diag();
102 while ( my $data = $input_file->getline($file_io) ) {
103 my $acc = $data->[0];
104 my $ensid = $data->[5];
106 my $xref_id = $self->add_xref(
112 source_id => $source_id,
113 species_id => $species_id,
114 info_type =>
'DIRECT',
119 $self->add_direct_xref( $xref_id, $ensid,
'Gene', undef, $dbi );
120 if ( exists $syn_hash->{$acc} ) {
121 foreach my $syn ( @{ $syn_hash->{$acc} } ) {
122 $self->add_to_syn( $acc, $source_id, $syn, $species_id, $dbi );
130 || confess
"Error parsing file $file: " . $input_file->error_diag();
134 print
"$count direct MGI xrefs added\n";
135 print $syn_count.
" synonyms added\n";