/usr/share/perl5/GO/Parsers/go_ids_parser.pm is in libgo-perl 0.15-5.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 | # $Id: go_ids_parser.pm,v 1.2 2007/08/03 01:52:23 sjcarbon Exp $
#
#
# see also - http://www.geneontology.org
# - http://www.godatabase.org/dev
#
# You may distribute this module under the same terms as perl itself
package GO::Parsers::go_ids_parser;
=head1 NAME
GO::Parsers::go_ids_parser - syntax parsing of flat files containing GO IDs.
=head1 SYNOPSIS
=head1 DESCRIPTION
do not use this class directly; use L<GO::Parser>
This generates Stag/XML event streams from files containing GO IDs.
Lines from such a file might be:
GO:0000003 GO:0000166 GO:0000228
GO:0000229
GO:0003674
GO:0003676 GO:0003677
GO:0003682
GO:0003700
GO:0003723 GO:0003774 GO:0003779 GO:0005634
GO:0005635
GO:0005654
See
L<http://www.godatabase.org/dev/xml/dtd/go_ids-parser-events.dtd>
For the DTD of the event stream that is generated
=cut
use Exporter;
use base qw(GO::Parsers::base_parser Exporter);
#use Text::Balanced qw(extract_bracketed);
use GO::Parsers::ParserEventNames;
use Carp;
use FileHandle;
use strict;
##
sub dtd {
'go_ids-parser-events.dtd';
}
##
sub parse_fh {
my ($self, $fh) = @_;
#my $file = $self->file;
my $term;
my $line_no = 0;
my %done = (); # Don't bother with things already done.
$self->start_event(OBO);
#$self->fire_source_event($file);
while (<$fh>) {
$line_no++;
# UNICODE causes problems for XML and DB
# delete 8th bit
tr [\200-\377]
[\000-\177]; # see 'man perlop', section on tr/
# weird ascii characters should be excluded
tr/\0-\10//d; # remove weird characters; ascii 0-8
# preserve \11 (9 - tab) and \12 (10-linefeed)
tr/\13\14//d; # remove weird characters; 11,12
# preserve \15 (13 - carriage return)
tr/\16-\37//d; # remove 14-31 (all rest before space)
tr/\177//d; # remove DEL character
## Skip if not there or comment.
next if ! $_;
next if /^\!/;
# some files use string NULL - we just use empty string as null
s/\\NULL//g;
$self->line($_);
$self->line_no($line_no);
## Remove leadng and trailing whitespace.
s/^[\s\n]+//;
s/[\s\n]+$//;
my @accs = split /\s+/;
for( my $i = 0; $i < @accs; $i++ ){
my $acc = $accs[$i];
## Massage a bit more.
if( $acc ){
next if $done{$acc}; # skip if done
##
if( $self->acc_not_found($acc) ){
$self->parse_err("No such ACC: $acc");
next;
}
$self->start_event(TERM);
$self->event(ID, $acc);
$self->end_event(TERM);
$done{$acc} = 1;
}
}
}
# This is causing problems during direct fh access.
$fh->close;
$self->pop_stack_to_depth(0);
}
1;
|