Bio-DB-TFBS

 view release on metacpan or  search on metacpan

t/transfac_pro.t  view on Meta::CPAN

		my %fragment_ids = map { $_ => 1 } $db->get_fragment_ids(-gene => 'G020751');
		ok $fragment_ids{'FR0002267'};
        # get_reference_ids(-gene => ...) already tested
    }
    
    # site.dat
    {
        ok my ($site_id) = $db->get_site_ids(-id => 'HS$IFI616_01');
        is $site_id, 'R00001';
        ok my $seq = $db->get_seq($site_id);
        isa_ok $seq, 'Bio::Seq';
        is $seq->id, 'HS$IFI616_01';
        is $seq->accession_number, 'R00001';
        is $seq->seq, 'aGAGACATAAGTgA';
        my $annot = $seq->annotation;
        is [$annot->get_Annotations('relative_start')]->[0]->value, -172;
        is [$annot->get_Annotations('relative_end')]->[0]->value, -98;
        is [$annot->get_Annotations('relative_type')]->[0]->value, 'TSS';
        is [$annot->get_Annotations('relative_to')]->[0]->value, 'G000176';
        is $seq->species, 9606;
        
        my @site_ids = $db->get_site_ids(-species => '9606');
        is @site_ids, 14;
        is [sort @site_ids]->[0], 'R00001';
        # get_site_ids(-gene => ...) already tested
        ($site_id) = $db->get_site_ids(-matrix => 'M00972');
        is $site_id, 'R00001';
        my %site_ids = map { $_ => 1 } $db->get_site_ids(-factor => 'T00428');
        ok $site_ids{R00001};
        # get_site_ids(-reference => ...) already tested
        
        # get_gene_ids(-site => ...) already tested
        my @matrix_ids = $db->get_matrix_ids(-site => 'R00001');
        is "@matrix_ids", 'M00972';
        my @factor_ids = $db->get_factor_ids(-site => 'R00001');
        is "@factor_ids", 'T00428';
        # get_reference_ids(-site => ...) already tested
    }
    
    # matrix.dat
    {
        ok my ($matrix_id) = $db->get_matrix_ids(-id => 'V$E47_01');
        is $matrix_id, 'M00002';
        ok my $matrix = $db->get_matrix($matrix_id);
        isa_ok $matrix, 'Bio::Matrix::PSM::SiteMatrix';
        
        # detailed psm tests
        {
            # Lets try to compress and uncompress the frequencies, see if
            # there is no considerable loss of data.
            my $fA = $matrix->get_compressed_freq('A');
            my @check = Bio::Matrix::PSM::SiteMatrix::_uncompress_string($fA,1,1);
            my @A = $matrix->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
            
            # SiteMatrixI methods
            is $matrix->id, 'V$E47_01';
            is $matrix->accession_number, $matrix_id;
            is $matrix->consensus, 'ATGCATGCATGC';
            is $matrix->IUPAC, 'NNNNNNNNNNNN';
            is $matrix->regexp, '\S\S\S\S\S\S\S\S\S\S\S\S';
            is $matrix->width, 12;
            is $matrix->sites, 5;
            ok ! $matrix->IC;
            ok ! $matrix->e_val;
        }
        
        ok my $aln = $db->get_aln($matrix_id);
        isa_ok $aln, 'Bio::SimpleAlign';
        is $aln->length, 12;
        is $aln->num_residues, 132;
        ok $aln->is_flush;
        is $aln->num_sequences, 11;
        my @ids = qw(R05108 R05109 R05110 R05111 R05112 R05113 R05114 R05115 R05116 R05117 R05118);
        foreach my $seq ($aln->each_alphabetically) {
            is $seq->id, shift(@ids);
        }
        is @ids, 0;
        ok ! $db->get_aln('M00001'); # no seqs in db
        ok $aln = $db->get_aln('M00001', 1); # force to find seqs, store in db
        ok $aln = $db->get_aln('M00001'); # seqs now in db
        is $aln->num_sequences, 5;
		
        ($matrix_id) = $db->get_matrix_ids(-name => 'MyoD');
        is $matrix_id, 'M00001';
        # get_matrix_ids(-site =>  ...) already tested
        my %matrix_ids = map { $_ => 1 } $db->get_matrix_ids(-factor => 'T00526');
        ok $matrix_ids{M00001};
        # get_matrix_ids(-reference => ...) already tested
        
        # get_site_ids(-matrix => ...) already tested
        my @factor_ids = $db->get_factor_ids(-matrix => 'M00001');
        is join(' ', sort @factor_ids), 'T00526 T09177';
        # get_reference_ids(-matrix => ...) already tested
    }
    
	# fragment.dat
	{
		ok my ($fragment_id) = $db->get_fragment_ids(-id => 'FR0002267');
        is $fragment_id, 'FR0002267'; # id and accession are the same for fragments
		ok my $seq = $db->get_fragment($fragment_id);
		isa_ok $seq, 'Bio::SeqI';
        is $seq->id, 'FR0002267';
        is $seq->seq, 'GTCTACAACACTCTTGCGGACGGAGAGCCGAAGAGCAAAGCGTCGCCGGGTAAGACGAACGCTCAAGGGGGTACGAGCAGCGTAACGACGGAAACGGTGACGCCCCGGGATTTGGGGCTCAGCTAGGGTCGCCGAGTAGGGGGCCGCGGGGACAACGGGGGCGACACGCCGCTTTCCCTGCGTCTGTGGAGCCTATGGTACGGCGTAACCGGTTGTGTGATGAACTG...
		is $seq->species, 9606;
		
        # -id -species -gene -factor -reference
        my @fragment_ids = $db->get_fragment_ids(-species => '9606');
        is @fragment_ids, 2;
        is [sort @fragment_ids]->[0], 'FR0000001';
        my %fragment_ids = map { $_ => 1 } $db->get_fragment_ids(-factor => 'T03828');
        ok $fragment_ids{'FR0002267'};
        # get_fragment_ids(-gene => ...) already tested
        # get_fragment_ids(-reference => ...) already tested



( run in 2.328 seconds using v1.01-cache-2.11-cpan-8f98c5d2c55 )