File Coverage

blib/lib/Bio/DOOP/Util/Filt.pm
Criterion Covered Total %
statement 6 66 9.0
branch 0 8 0.0
condition n/a
subroutine 2 6 33.3
pod 4 4 100.0
total 12 84 14.2


line stmt bran cond sub pod time code
1             package Bio::DOOP::Util::Filt;
2              
3 1     1   7 use strict;
  1         2  
  1         50  
4 1     1   7 use warnings;
  1         2  
  1         635  
5              
6             =head1 NAME
7              
8             Bio::DOOP::Util::Filt - Filter a cluster list
9              
10             =head1 VERSION
11              
12             Version 0.3
13              
14             =cut
15              
16             our $VERSION = '0.3';
17              
18             =head1 SYNOPSIS
19              
20             use Bio::DOOP::DOOP;
21              
22             @list = ("81001020","81001110","81001200","80100006");
23             $db = Bio::DOOP::DBSQL->connect("username","passwd","doop-chordate-1_4","localhost");
24             $filt = Bio::DOOP::Util::Filt->new_by_list($db,\@list,500);
25              
26             @res = @{$filt->filt_by_goid("0046872")};
27             for(@res){
28             print $_->get_cluster_id,"\n";
29             }
30              
31             =head1 DESCRIPTION
32              
33             This object filters a clusterlist. It is useful to find a smaller cluster set from a
34             large mofext or fuzznuc search result.
35              
36             =head1 AUTHORS
37              
38             Tibor Nagy, Godollo, Hungary and Endre Sebestyen, Martonvasar, Hungary
39              
40             =head1 METHODS
41              
42             =head2 new
43              
44             Creates a new filter object from a cluster object array.
45              
46             =cut
47              
48             sub new {
49 0     0 1   my $self = {};
50 0           my $dummy = shift;
51 0           my $db = shift;
52 0           my $clarray = shift;
53 0           my $prom = shift;
54              
55 0           $self->{CLARRAY} = $clarray;
56 0           $self->{DB} = $db;
57 0           $self->{PROM} = $prom;
58              
59 0           bless $self;
60 0           return($self);
61             }
62              
63             =head2 new_by_list
64              
65             Creates a new filter class from a cluster id array.
66              
67             =cut
68              
69             sub new_by_list {
70 0     0 1   my $self = {};
71 0           my $dummy = shift;
72 0           my $db = shift;
73 0           my $clarray_id = shift;
74 0           my $prom = shift;
75 0           my @clarray;
76              
77 0           for my $id (@{$clarray_id}){
  0            
78 0           my $cl = Bio::DOOP::Cluster->new($db,$id,$prom);
79 0 0         if ($cl == -1){
80 0           next;
81             }
82 0           push @clarray,$cl;
83             }
84              
85 0           $self->{CLARRAY} = \@clarray;
86 0           $self->{DB} = $db;
87 0           $self->{PROM} = $prom;
88              
89 0           bless $self;
90 0           return($self);
91             }
92              
93             =head2 new_by_id
94              
95             Creates a new filter class from a cluster primary id array.
96              
97             =cut
98              
99             sub new_by_id {
100 0     0 1   my $self = {};
101 0           my $dummy = shift;
102 0           my $db = shift;
103 0           my $clarray_id = shift;
104 0           my @clarray;
105              
106 0           for my $id (@{$clarray_id}){
  0            
107 0           my $cl = Bio::DOOP::Cluster->new_by_id($db,$id);
108 0 0         if ($cl == -1){
109 0           next;
110             }
111 0           push @clarray,$cl;
112             }
113              
114 0           $self->{CLARRAY} = \@clarray;
115 0           $self->{DB} = $db;
116              
117 0           bless $self;
118 0           return($self);
119             }
120              
121             =head2 filt_by_goid
122              
123             Filter the cluster list by GO ids.
124              
125             @filtered = @{$filt->filt_by_goid("0006523")};
126              
127             =cut
128              
129             sub filt_by_goid {
130 0     0 1   my $self = shift;
131 0           my $goid = shift;
132              
133 0           my @cl = @{$self->{CLARRAY}};
  0            
134 0           my @ret;
135              
136 0           CLUSTER:for my $cl (@cl){
137 0           my @seqs = @{$cl->get_all_seqs};
  0            
138 0           for my $seq (@seqs){
139 0           my $goids = $seq->get_xref_value("go_id");
140 0 0         if ($goids == -1){next}
  0            
141 0           for my $id (@{$goids}){
  0            
142 0 0         if ($id eq $goid){
143 0           push @ret,$cl;
144 0           next CLUSTER;
145             }
146             }
147             }
148             }
149              
150 0           return(\@ret);
151             }
152              
153             1;