File: LogicalDefinition.pm

package info (click to toggle)
libgo-perl 0.15-10
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 8,112 kB
  • sloc: perl: 13,147; sh: 21; makefile: 7
file content (105 lines) | stat: -rw-r--r-- 1,870 bytes parent folder | download | duplicates (5)
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
# $Id: LogicalDefinition.pm,v 1.1 2006/04/05 22:47:57 cmungall Exp $
#
# This GO module is maintained by Chris Mungall <cjm@fruitfly.org>
#
# 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::Model::LogicalDefinition;

=head1 NAME

  GO::Model::LogicalDefinition - logical definition

=head1 SYNOPSIS

=head1 DESCRIPTION

=cut


use Carp qw(cluck confess);
use Exporter;
use GO::Utils qw(rearrange);
use GO::Model::Root;
use strict;
use vars qw(@ISA);

@ISA = qw(GO::Model::Root Exporter);

sub _valid_params {
    return qw(intersection_list);
}

=head2 intersection_list

 Usage   -
 Returns -
 Args    -

Each element of the list is itself a list

This list is of length 1 or 2.

  [$generic_term_acc]
  [$relation,$differentiating_term_acc]

=cut


=head2 generic_term_acc

  Usage   -
  Synonyms - genus_acc
  Returns -
  Args    -

the ID of the generic term, also known as 'genus'

=cut

sub generic_term_acc {
    my $self = shift;
    if (@_) {
        my $acc = shift;
        my $diffs = $self->differentia;
        push(@{$self->intersection_list},$acc);
        return $acc;
    }
    my @direct_accs =
      grep {scalar(@$_) == 1} @{$self->intersection_list};
    if (@direct_accs > 1) {
        $self->throw("multiple generic terms");
    }
    if (@direct_accs) {
        return $direct_accs[0]->[0]; 
    }
    # no genus
    return;
}
*genus_acc = \&generic_term_acc;

=head2 differentia

Usage   -
 Returns -
 Args    -

=cut

sub differentia {
    my $self = shift;
    if (@_) {
        my $diffs = shift;
        my $genus = $self->generic_term_acc;
        $self->intersection_list([$genus, $diffs]);
        return $diffs;
    }
    my @diffs =
      grep {scalar(@$_) > 1} @{$self->intersection_list};
    return \@diffs;
}

1;