/usr/share/perl5/SWISS/OSs.pm is in libswiss-perl 1.67-1.1.
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 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 | package SWISS::OSs;
use vars qw($AUTOLOAD @ISA @EXPORT_OK %fields);
use Exporter;
use Carp;
use strict;
use SWISS::TextFunc;
use SWISS::ListBase;
use SWISS::OS;
BEGIN {
@EXPORT_OK = qw();
@ISA = ( 'Exporter', 'SWISS::ListBase');
%fields = (
);
}
sub new {
my $ref = shift;
my $class = ref($ref) || $ref;
my $self = new SWISS::ListBase;
$self->rebless($class);
return $self;
}
sub initialize {
}
sub fromText {
my $self = new(shift);
my $textRef = shift;
my $line;
my @tmp;
if ($$textRef =~ /($SWISS::TextFunc::linePattern{'OS'})/m){
$line = $1;
$self->{indentation} = $line =~ s/^ //mg;
$line = SWISS::TextFunc->joinWith('', ' ', '(?<! )[-/]', 'and ',
map {SWISS::TextFunc->cleanLine($_)}
(split "\n", $line));
# complex expression for separator to make sure commas within brackets are
# not regarded as separators.
@tmp = SWISS::TextFunc->listFromText($line, ',\s+(?i:and\s+)?(?![^\(]+\))', '\.');
@tmp = map {SWISS::OS->fromText($_)} @tmp;
push (@{$self->list()}, @tmp);
}
$self->{_dirty} = 0;
return $self;
}
sub toText {
my $self = shift;
my $textRef = shift;
my (@tmp, @lines);
my $newText = '';
my $lastElementRef;
my $listRef;
if ($self->size > 0) {
@tmp = map {$_->toText} $self->elements();
# Add commas as separators
map {$_ .= ','} @tmp;
# delete last comma
$tmp[$#tmp] =~ s/\,$//;
# drop trailing spaces and dots
# (Rattus SP.)
$tmp[$#tmp] =~ s/[\. ]+(($SWISS::TextFunc::evidencePattern)*$)/$1/m;
# add final dot
$tmp[$#tmp] .= '.';
# insert an 'and' after the last but one species
if ($#tmp > 0) {
$tmp[$#tmp-1] .= ' and';
}
# wrap lines where one OS extends beyond one line
for (my $i=0; $i<@tmp; $i++) {
my $prefix = "OS ";
my $col = $SWISS::TextFunc::lineLength;
$col++, $prefix=" $prefix" if $self->{indentation};
$tmp[$i] = SWISS::TextFunc->wrapOn($prefix, $prefix, $col,
$tmp[$i],
'\s+');
}
# connect all OS lines
$newText = join('', @tmp);
};
$self->{_dirty} = 0;
return SWISS::TextFunc->insertLineGroup($textRef, $newText,
$SWISS::TextFunc::linePattern{'OS'});
}
# OSs must never be sorted, overwrite the inherited sort method.
sub sort {
return 1;
}
# convert scientific name to the abbreviated form as it is used
# in the RC SPECIES line
# input $scientific: Full scientific name (e.g. 'Escherichia coli')
# $superregnum: 'V' for viruses, 'E' for eukaryotes etc.
# (By now, only 'V' or not 'V' is important
# returns abbreviated name (e.g. 'E.coli')
sub scientific2rc {
my $scientific = shift;
my $superregnum = shift;
unless ($scientific) {
croak "No input";
return undef;
}
my $rc = $scientific;
my %common=
('RATTUS NORVEGICUS' => 'Rat',
'HOMO SAPIENS' => 'Human',
'MUS MUSCULUS' => 'Mouse',
'BOS TAURUS' => 'Bovine',
'GALLUS GALLUS' => 'Chicken',
'SUS SCROFA' => 'Pig',
'ORYCTOLAGUS CUNICULUS' => 'Rabbit',
'OVIS ARIES' => 'Sheep',
'ZEA MAYS' => 'Maize',
'EQUUS CABALLUS' => 'Horse',
'GLYCINE MAX' => 'Soybean',
);
if ($superregnum eq 'V') {
$rc =~ s/\bBACTERIO(PHAGE)/$1/i;
return $rc;
} else {
my $common = $common{uc($scientific)};
return $common if $common;
return $scientific if $scientific =~ /^\w+ SP\.$/i;
my $done = 0;
die "no input" unless $rc;
$done ||= ($rc =~ s/^(\w)\w+ ([A-Z\-]+)$/$1.$2/i);
$done ||= ($rc =~ s/^(\w)\w+ (\w)[A-Z\-]+ ([A-Z\-]+)$/$1.$2.$3/i);
$done ||= ($rc =~ s/^(\w)\w+ \(STRAIN (.*)\)$/$1.$2/i);
$done ||= ($rc =~ s/^(\w)\w+ SP\. \(STRAIN (.*)\)$/$1.$2/i);
$done ||= ($rc =~ s/^(\w)\w+ SP\.$/$1.$2/i);
$done ||= ($rc =~ s/^(\w)\w+ X ([A-Z\-]+)$/$1.$2/i);
if (!$done){
my $infix;
foreach $infix ('SUBSP\.','STRAIN','VAR\.','PV\.','BIOVAR',
'BV\.','F\. SP\.' ){
$done ||= ($rc =~ s/^(\w)\w+ (\w)[A-Z\-]+ $infix (.*)$/$1.$2.$3/i);
$done ||= ($rc =~ s/^(\w)\w+ (\w)[A-Z\-]+ \($infix (.*)\)$/$1.$2.$3/i);
last if $done;
}
}
return $done ? $rc : '';
}
}
1;
__END__
=head1 Name
SWISS::OSs
=head1 Description
B<SWISS::OSs> represents the OS lines within an SWISS-PROT + TrEMBL
entry as specified in the user manual
http://www.expasy.org/sprot/userman.html . The OSs object is a container object which holds a list of SWISS::OS objects.
=head1 Inherits from
SWISS::ListBase.pm
=head1 Attributes
=over
=item C<list>
Each list element is a SWISS::OS object.
=back
=head1 Methods
=head2 Standard methods
=over
=item new
=item fromText
=item toText
=back
|