This file is indexed.

/usr/share/perl5/SWISS/CCs.pm is in libswiss-perl 1.67-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
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
package SWISS::CCs;

use vars qw($AUTOLOAD @ISA @EXPORT_OK %fields %TOPICS);

use Exporter;
use Carp;
use strict;

use SWISS::TextFunc;
use SWISS::ListBase;
use SWISS::CC;
use SWISS::CCcopyright;
use SWISS::CCalt_prod;
use SWISS::CCrna_editing;
use SWISS::CCbpc_properties;
use SWISS::CCinteraction;
use SWISS::CCseq_caution;


BEGIN {
  @EXPORT_OK = qw();
  
  @ISA = ( 'Exporter', 'SWISS::ListBase');
  
  %fields = (
	    );  
}

#initialization code: stuff DATA into hash
{
  # Leading and trailing spaces are MANDATORY!
  local $/="\n";
  my $index=0;
  my $line;
  while (defined ($line=<DATA>)) {
    $line =~ s/\s+\z//;
    $TOPICS{$line} = $index++;
  }
  $TOPICS{'Copyright'} = $index++;
  close DATA;
}

sub new {
  my $ref = shift;
  my $class = ref($ref) || $ref;
  my $self = new SWISS::ListBase;
  
  $self->rebless($class);
  return $self;
}

sub fromText {
  
  my $self = new(shift);
  my $textRef = shift;
  my $line;
  my @tmp;

  if ($$textRef =~ /($SWISS::TextFunc::linePattern{'CC'})/m) {   
    
    my $block = $1;
    my ($main, $copyright) = split /CC   +-{40,78}\nCC/, $block;
    
    # can't get regexp to work with two optional components to a block
    #  ($block =~ /(.*)?(CC   -{40,78}\n(.*\n)*CC   -{40,78})*\n/s);
    
    # process each non-copyright comment type
    foreach $line (split /\n(?= ?CC   +-!-)/m, $main) {
      
      my $indentation = $line =~ s/^ //mg;
      $line = SWISS::TextFunc->cleanLine($line);
      my $cc = _chooseType($line); 
      $cc->{indentation} = $indentation if $indentation;
      push (@{$self->list()}, $cc); 
    }
    
    # process copyright
    if (defined $copyright) {
      $copyright =  "CC   -----------------------------------------------------------------------\nCC".$copyright;
      $copyright =~ s/-{40,78}\r?\n$/-----------------------------------------------------------------------/;
      push (@{$self->list()}, _chooseType($copyright)); 
    }
  } 
  $self->{_dirty} = 0;
  return $self;
}

sub toText {
  my $self = shift;
  my $textRef = shift;
  my @lines;
  my $newText = '';

  if (! $self->isEmpty()){
  
    $newText = join('', map {
      my $str = $_->toString();
      $str =~ s/^/ /mg if $_->{indentation};
      $str;
      } @{$self->list});
  };

  $self->{_dirty} = 0;
  return SWISS::TextFunc->
    insertLineGroup($textRef, $newText, $SWISS::TextFunc::linePattern{'CC'});
}

sub toString {
  
  my $self = shift;
  my $string = "";
  $self -> toText(\$string);
  return $string;
}

sub _chooseType {

  my $text = shift;
  my $CCs;
  
  # preparse text into a single line 
  
  $text =~ s/-\nCC {7}(AND|OR) /- $1 /mgi;
  # unwrap things like '-Val- bond' and 'Leu-|- bonds' (but not 'disulfide-bond') with space
  $text =~ s/(\b[A-Z]{3}-|-\|-)\nCC {7}(BOND)/$1 $2/mgi;
  $text =~ s/(?<!\/)-\nCC {7,}/-/mg;# wrap dash cr without space (except in "+/-")
  $text =~ s/\nCC {7}/ /mg;    # wrap other cr with space
  $text =~ s/^CC   -!-\s*//mg; # strip line tags and spaces
  $text =~ s/[\.\s]+$//mg;     # and trailing dots and spaces
  
  # get one of three types of objects as is appropriate

  if ($text !~ /-\!/) {
  
    ## copyright notice
    
    $text =~ s/[\.\s]+$//mg; 
    $CCs = SWISS::CCcopyright->fromText(\$text);
  
  }  elsif (($text =~ /-!- ALTERNATIVE PRODUCTS/) && ($text =~ /Event=/)) {
  
    # new format alternative products
    
    $CCs = SWISS::CCalt_prod->fromText(\$text);
  
  }  elsif (($text =~ /-!- BIOPHYSICOCHEMICAL PROPERTIES/)) {
    $CCs = SWISS::CCbpc_properties->fromText(\$text);
  }  elsif (($text =~ /-!- INTERACTION/)) {
    $CCs = SWISS::CCinteraction->fromText(\$text);
  }  elsif (($text =~ /-!- RNA EDITING/)) {
    $CCs = SWISS::CCrna_editing->fromText(\$text);
  }  elsif (($text =~ /-!- SEQUENCE CAUTION/)) {
    $CCs = SWISS::CCseq_caution->fromText(\$text);
  } else {
  
    # standard
    $CCs = SWISS::CC->fromText(\$text);
  }
  
  return $CCs;
}

sub sort {
  my $self = shift;
  my $n = $self->size();  return 1 if $n < 2;
  my $rary = $self->list();
  my $disorder;
  # nearly all entries will be in order, so test for it
  for (my $i=1; $i<$n; $i++) {
    if (_sort_cmp($rary->[$i-1], $rary->[$i]) > 0){
      $disorder=1;
      last;
    } 
  }
  return 1 unless $disorder;
 
  # simple sort to preserve order of same topics
  for (my $i=1; $i < $n; $i++){ 
    for (my $j=1; $j < $n; $j++){
      if (_sort_cmp($rary->[$j-1], $rary->[$j]) > 0){
        ($rary->[$j-1],$rary->[$j]) = ($rary->[$j],$rary->[$j-1]); 
      }
    }
  }
  return 1;
}

sub _sort_cmp {
	my ($cc1, $cc2) = @_;
	my $topic_1 = $cc1->topic;
	my $topic_2 = $cc2->topic;

	if ($topic_1 eq 'SIMILARITY' && $topic_2 eq 'SIMILARITY') {
		my $c_1 = $cc1->comment;
		my $c_2 = $cc2->comment;
		my @ord;
		for my $c ($c_1, $c_2) {
			if ($c =~ /\bbelongs to\b/i) {
				push @ord, 1;
			}
			elsif ($c =~ /^Contains\b/i) {
				push @ord, 2;
			}
			else {
				push @ord, 3;
			}
		}
		return $ord[0] <=> $ord[1] if $ord[0] != $ord[1];
		if ($c_1 =~ /^CONTAINS (?:AT LEAST )?(?:\d+|\?) (.*)/i) {
			my $t_1 = $1;
			if ($c_2 =~ /^CONTAINS (?:AT LEAST )?(?:\d+|\?) (.*)/i) {
				return lc($t_1) cmp lc($1) || $t_1 cmp $1;
			}
		}
		return 0;
	}
	return $TOPICS{$topic_1} <=> $TOPICS{$topic_2};
}


sub update {
  my $self = shift;
  my $force = shift;
  # CCs should be sorted, but unique() does not make sense
  $self->sort();
  return 1;
}


sub get {

  # local override of global get method
  # get array of CC objects selected by topic

  my ($self, @patterns) = @_;
  my @result;

  # do nothing if the list is empty
  unless ($self->size > 0 ) {
    return ();
  };

  if ((ref $patterns[0] eq 'ARRAY')) {
    @patterns = @{$patterns[0]};
  };

  @result = @{$self->list};
  # empty patterns are regarded as matches.
  if (defined($patterns[0]) and $patterns[0] ne ""){
    @result = grep { $_->topic() =~ /^$patterns[0]$/ } @result;
  }
  if (defined($patterns[1]) and $patterns[1] ne ""){
    @result = grep { $_->comment() =~ /^$patterns[1]$/ } @result;
  }
  return @result;
}

sub unique {
  my ($self) = @_;

  my ($i, $j);
  for ($i = 0; $i < $#{$self->{list}}; $i++) {
    my $item1 = ${$self->list}[$i];
    for ($j = $i+1; $j <= $#{$self->{list}}; $j++) {
      my $item2 = ${$self->list}[$j];
      if ($item1->topic eq $item2->topic and $item1->comment eq $item2->comment) {
        splice @{$self->list}, $j--, 1;
      }
    }
  }
  return 1;
}

sub getObject {

  # local override of global get method
  # get ListBase object of CC objects selected by topic

  my ($self, @patterns) = @_;
  my @result;
  my $new;
  $new = new ref($self);
  $new->set($self -> get(@patterns));
  return $new;
}

sub del {

  # local override of global del method
  # delete CC objects if topic matches that specified
  
  my ($self, @patterns) = @_;
  my @result;
  my ($i, $pat, @elements);
  
  # do nothing if the list is empty
  
  unless ($self->size > 0 ) {
    return ();
  };

  @elements = @{$self->list};
  
  ELEMENT:for my $element (@elements) {  
    
    my $match = 0;
   
    if ($patterns[0]  && ($element->topic() =~ /^$patterns[0]$/)) {
	  
      if ((! $patterns[1]) || ($element->comment() =~ /^$patterns[1]$/)) {
          
        $match ++; 
      }
    }
    
    if ($match == 0) { 
      
      CORE::push (@result, $element);
	  }
	}
  
  return $self->set(@result);
}

sub copyright {

  # retrive copyright 
  
  my ($self) = @_;
  my @elements = @{$self->list};
  
  ELEMENT:for my $element (@elements) { 
  
    if ($element->topic() eq 'Copyright') {
    
      return $element -> toString();
    } 
  }
   
  return; 
}

sub ccTopic{
  my ($ccTopic) = @_;
  
  return sub {
    my $ref = shift;
    my $topic = $ref -> topic();

    return ($topic eq $ccTopic);
  }  
}


1;

=head1 Name

SWISS::CCs

=head1 Description

B<SWISS::CCs> represents the CC lines within a Swiss-Prot or TrEMBL
entry as specified in the user manual
 http://www.expasy.org/sprot/userman.html . The CCs object is a 
container object which holds a list comprised of object of
the type SWISS::CC or derived classes (see below).

B<Code example>

local $/="\n//\n";
 
while (<>) {
 
  my $entry = SWISS::Entry-> fromText($_);
  my @CCs = $entry -> CCs -> elements();
 
  for my $CC (@CCs) {
     
    if ($CC -> topic eq 'ALTERNATIVE PRODUCTS') {
    
      # now can call methods of CCalt_prod 
    
    } elsif ($CC -> topic eq 'Copyright') {
    
      # now can call methods of CCcopyright
    
    } else {
    
      # now can call methods of CC
    }
  }
}

=head1 Inherits from

SWISS::ListBase.pm

=head1 Attributes

=over

=item C<list>

Each list element is an object of one of the following classes,
depending of the type of comment:

 topic                           object
 --------------------            --------------------
 ALTERNATIVE PRODUCTS            SWISS::CCalt_prod
 RNA EDITING                     SWISS::CCrna_editing
 BIOPHYSICOCHEMICAL PROPERTIES   SWISS::CCbpc_properties
 INTERACTION                     SWISS::CCinteraction
 Copyright                       SWISS::CCcopyright
 (all other topics)              SWISS::CC

=back

=head1 Methods

=head2 Standard methods

=over

=item new

=item fromText

=item sort

Sort the CC block according to the order given in Swiss-Prot annotation
note ANN017.

=item toText

=item update

=back

=head2 Reading/Writing methods

=over

=item ccTopic ($topic)

Returns true if entry contains a comment block with the specified topic.

=item copyright

Returns a string representation of the copyright text.

=item del (@patternList)

Deletes all comment elements whose topic matches the first element
of the pattern list.  The second element is the used to specify a
requirement for the comment to match as well.

=item get (@patternList)

An array is returned consisting of all comment elements
elements whose topic matches any elements of the pattern list.

=item getObject (@patternList)

Same as get, but returns the results wrapped in a new ListBase object.  

=item toString

Returns a string representation of the CCs object.

=back

=cut

__DATA__
FUNCTION
CATALYTIC ACTIVITY
COFACTOR
ENZYME REGULATION
BIOPHYSICOCHEMICAL PROPERTIES
PATHWAY
SUBUNIT
INTERACTION
SUBCELLULAR LOCATION
ALTERNATIVE PRODUCTS
TISSUE SPECIFICITY
DEVELOPMENTAL STAGE
INDUCTION
DOMAIN
PTM
RNA EDITING
MASS SPECTROMETRY
POLYMORPHISM
DISEASE
ALLERGEN
TOXIC DOSE
BIOTECHNOLOGY
PHARMACEUTICAL
MISCELLANEOUS
SIMILARITY
CAUTION
SEQUENCE CAUTION
DATABASE
WEB RESOURCE