File: ProtPsm.t

package info (click to toggle)
bioperl 1.7.7-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 35,888 kB
  • sloc: perl: 94,151; xml: 14,982; makefile: 20
file content (75 lines) | stat: -rw-r--r-- 2,414 bytes parent folder | download | duplicates (2)
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
# -*-Perl-*- Test Harness script for Bioperl
# $Id$


use strict;

BEGIN {
   use Bio::Root::Test;
   
   test_begin(-tests => 14);
   
   use_ok('Bio::Matrix::PSM::IO');
}

# Test psiblast reading functionality.
my $psmIO =  Bio::Matrix::PSM::IO->new(-format => 'psiblast', 
			      -file   => test_input_file('atp1.matrix'));
ok $psmIO;

my $psm = $psmIO->next_psm;
ok $psm;

# Verify that getting IUPAC sequence is functional
my $IUPAC = 'MEMSINPSEISSIIKEQIENYDTKAEVSEVGTVLSVGDGIARVYGLDNVMAGEMVEFPSGVKGMALNLEEDNVGVVLLGDDTGIKEGDLVKRTGKIVEVPVGEALLGRVVDPLGNPIDAKGPIKTDERRPVEVKAPGIIPRKSVHEPLQTGLKAIDSLVPIGRGQRELIIGDRQTGKTAIAIDTIINQKRINDESTDEGKKVYCIYVAIGQKRSTVAQVVQTLREAGALEYTIIVAATAAAPAPAQYLSAYAGCAIGEAFADNGAAACIIHDDLSRQAVAYAIISLLLRRPPGREAYPGDVFYLHSRLLERAAKLSDELGGGSLTALPIIETQAGDVSAYIPTNVISITDGQIFLETDLFNSGIRPAINVGLSVSRVGSAAQIKAMKKVAGSLKLELAQYRELAAFAQFGSDLDAATQAQLNRGARLTELLKQPQYSPLPVEEQVVILYAGVNGYLDDIPVEDIRDFEKELLEYLKSNHPEILESIRTGKLSDEIEKALKEAIKEFV';
is $psm->IUPAC, $IUPAC;

## Lets try to compress and uncompress the log odds and the
## frequencies, see if there is no considerable loss of data.
SKIP: {
   skip('TODO: Module incomplete',10); 
   my $fA=$psm->get_compressed_freq('A');
   my @check=Bio::Matrix::PSM::SiteMatrix::_uncompress_string($fA,1,1);
   my @A=$psm->get_array('A');
   my ($var,$max) = (0,0);
   
   for (my $i = 0; $i<@check;$i++) {
     my $diff=abs(abs($check[$i])-abs($A[$i]));
     $var += $diff;
     $max=$diff if ($diff>$max);
   }
   my $avg=$var/@check;
   cmp_ok $avg,'<',0.01; #Loss of data under 1 percent
   is $psm->sequence_match_weight('CAGAAAAATAAAATGGCCACCACCC'),2015;
   
   my $lA=$psm->get_compressed_logs('A');
   @check=Bio::Matrix::PSM::SiteMatrix::_uncompress_string($lA,1000,2);
   @A=$psm->get_logs_array('A');
   ($var,$max) = (0,0);
   for (my $i = 0;$i<@check;$i++) {
     my $diff=abs(abs($check[$i])-abs($A[$i]));
     $var += $diff;
     $max=$diff if ($diff>$max);
   }
   $avg=$var/@check;
   cmp_ok $avg,'<',10; #Loss of data under 1 percent
   
   my $matrix=$psm->matrix;
   ok $matrix;
   my $psm2=$psm;
   $psm2->matrix($matrix);
   is $psm,$psm2;
   
   is $IUPAC,'CAGAAAAATWVAATYCCCACCHCCC';
   is $IUPAC,$psm2->IUPAC;
   is $IUPAC,$matrix->IUPAC;
   
   my $instances=$psm->instances;
   ok $instances;
   
   foreach my $instance (@{$instances}) {
     my $id=$instance->primary_id;
     is $instance->strand,1;
     last if (ok $id);
   }
}