Add tests for memory leaks and weaken for Issue #81
[bioperl-live.git] / t / SeqFeature / Gene.t
blobb4044309c7b856e04dc5b13eb2d782c786c18478
1 # -*-Perl-*- Test Harness script for Bioperl
2 # $Id$
4 use strict;
6 BEGIN { 
7     use lib '.';
8     use Bio::Root::Test;
9     
10     test_begin(-tests => 28);
12     use_ok('Bio::SeqIO');
13     use_ok('Bio::SeqFeature::Gene::Transcript');
14     use_ok('Bio::SeqFeature::Gene::UTR');
15     use_ok('Bio::SeqFeature::Gene::Exon');
16     use_ok('Bio::SeqFeature::Gene::Poly_A_site');
17     use_ok('Bio::SeqFeature::Gene::GeneStructure');
18     use_ok('Bio::Location::Fuzzy');
22 my ( $seqio, $geneseq, $gene, $transcript, $poly_A_site1, $poly_A_site2,
23      $fiveprimeUTR, $exon);
25 # tests for Bio::SeqFeature::Gene::* objects
26 # using information from acc: AB077698 as a guide
28 ok $seqio = Bio::SeqIO->new(
29     -format => 'genbank',
30     -file   => test_input_file('AB077698.gb'),
33 ok $geneseq = $seqio->next_seq();
35 ok $gene = Bio::SeqFeature::Gene::GeneStructure->new(
36     -primary => 'gene',
37     -start   => 1,
38     -end     => 2701,
39     -strand  => 1,
42 ok $transcript = Bio::SeqFeature::Gene::Transcript->new(
43     -primary => 'CDS',
44     -start   => 80,
45     -end     => 1144,
46     -tag     => { 
47         'gene' => "CHCR",
48         'note' => "Cys3His CCG1-Required Encoded on BAC clone RP5-842K24 (AL050310) The human CHCR (Cys3His CCG1-Required) protein is highly related to EXP/MBNL (Y13829, NM_021038, AF401998) and MBLL (NM_005757,AF061261), which together comprise the human Muscleblind family",
49        'codon_start' => 1,
50        'protein_id'  => 'BAB85648.1',
51     }
54 ok $poly_A_site1 = Bio::SeqFeature::Gene::Poly_A_site->new(
55     -primary => 'polyA_site',
56     -start => 2660,
57     -end   => 2660,
58     -tag   => { 
59         'note' => "Encoded on BAC clone RP5-842K24 (AL050310); PolyA_site#2 used by CHCR EST clone DKFZp434G2222 (AL133625)"
60     }
63 ok $poly_A_site2 = Bio::SeqFeature::Gene::Poly_A_site->new(
64     -primary => 'polyA_site',
65     -start => 1606,
66     -end   => 1606,
67     -tag   => { 
68         'note' => "Encoded on BAC clone RP5-842K24 (AL050310); PolyA_site#1 used by CHCR EST clone PLACE1010202 (AK002178)",
69     }
72 ok $fiveprimeUTR = Bio::SeqFeature::Gene::UTR->new(-primary => "utr5prime");
73 ok $fiveprimeUTR->location(
74     Bio::Location::Fuzzy->new(
75         -start => "<1",
76         -end   => 79,
77     )
79 ok my $threeprimeUTR = Bio::SeqFeature::Gene::UTR->new(
80     -primary => "utr3prime",
81     -start   => 1145,
82     -end     => 2659,
85 # Did a quick est2genome against genomic DNA (this is on Chr X) to
86 # get the gene structure by hand since it is not in the file
87 # --Jason
89 ok $exon = Bio::SeqFeature::Gene::Exon->new(
90     -primary => 'exon',
91     -start => 80,
92     -end   => 177,
94 ok $geneseq->add_SeqFeature($exon);
96 ok $geneseq->add_SeqFeature($fiveprimeUTR);
97 ok $geneseq->add_SeqFeature($threeprimeUTR);
98 ok $geneseq->add_SeqFeature($poly_A_site1);
99 ok $geneseq->add_SeqFeature($poly_A_site2);
101 ok $transcript->add_utr($fiveprimeUTR, 'utr5prime');
102 ok $transcript->add_utr($threeprimeUTR, 'utr3prime');
104 ok $transcript->add_exon($exon);
106 # API only supports a single poly-A site per transcript at this point 
107 $transcript->poly_A_site($poly_A_site2);
108 $geneseq->add_SeqFeature($transcript);
109 $gene->add_transcript($transcript);
110 $geneseq->add_SeqFeature($gene);
112 my ($t) = $gene->transcripts(); # get 1st transcript
113 ok(defined $t); 
114 is($t->mrna->length, 1693, 'mRNA spliced length');
115 is($gene->utrs, 2, 'has 2 UTRs');