New INSTALL.WIN doc (from wiki)
[bioperl-live.git] / t / Assembly.t
blob92208f4993df2143a874d15530f64ae4c6e4b40b
1 # This is -*-Perl-*- code
2 ## Bioperl Test Harness Script for Modules
3 ##
4 # $Id$
6 # Before `make install' is performed this script should be runnable with
7 # `make test'. After `make install' it should work as `perl test.t'
9 use strict;
10 use vars qw($NUMTESTS $DEBUG);
11 $DEBUG = $ENV{'BIOPERLDEBUG'} || 0;
13 my $error;
15 BEGIN {
16     # to handle systems with no installed Test module
17     # we include the t dir (where a copy of Test.pm is located)
18     # as a fallback
19     eval { require Test; };
20     $error = 0;
21     if( $@ ) {
22         use lib 't';
23     }
24     use Test;
26     $NUMTESTS = 19;
27     plan tests => $NUMTESTS;
28     eval { require DB_File };
29     if( $@ ) {
30                  print STDERR "DB_File not installed. This means the Assembly modules are not available.  Skipping tests.\n";
31                  for( 1..$NUMTESTS ) {
32                          skip("DB_File not installed",1);
33                  }
34                  $error = 1; 
35     }
39 END {
40         foreach ( $Test::ntest..$NUMTESTS) {
41                 skip('unable to run all of the DB tests',1);
42         }
45 if( $error ==  1 ) {
46     exit(0);
49 #syntax test
51 require Bio::Assembly::IO;
52 require Bio::Assembly::Scaffold;
53 require Bio::Assembly::Contig;
54 require Bio::Assembly::ContigAnalysis;
56 use Data::Dumper;
58 ok 1;
61 # Testing IO
64 # -file => ">".Bio::Root::IO->catfile("t","data","primaryseq.embl")
66 ok my $in = Bio::Assembly::IO->new
67     (-file=>Bio::Root::IO->catfile
68      ("t","data","consed_project","edit_dir","test_project.phrap.out"));
70 ok my $sc = $in->next_assembly;
71 #print Dumper $sc;
74 # Testing Scaffold
78 ok $sc->id, "NoName";
79 ok $sc->id('test'), "test";
81 ok $sc->annotation;
82 skip "no annotations in Annotation collection?", $sc->annotation->get_all_annotation_keys, 0;
83 ok $sc->get_nof_contigs, 1;
84 ok $sc->get_nof_sequences_in_contigs, 2;
85 skip "should return a number", $sc->get_nof_singlets, 0;
86 skip $sc->get_seq_ids, 2;
87 skip $sc->get_contig_ids, 1;
88 skip "nothing to test", $sc->get_singlet_ids;
92 # Testing Contig
96 # Testing ContigAnalysis
100 # Testing Ace 
103 my $aio = Bio::Assembly::IO->new(
104     -file=>Bio::Root::IO->catfile
105      ("t","data","consed_project","edit_dir","test_project.fasta.screen.ace.2"),
106     -format=>'ace',
109 my $assembly = $aio->next_assembly();
110 my @contigs = $assembly->all_contigs();
112 my $direction = $contigs[0]->strand;
113 ok $direction, 1;
115 my $features =  $contigs[0]->get_features_collection;
116 my @contig_features = $features->get_all_features;
117 ok @contig_features, 8;
119 my @annotations = grep {$_->primary_tag eq 'Annotation'} @contig_features;
120 ok @annotations, 2;
121 my $had_tag = 0;
122 foreach my $an (@annotations) {
123         if ($an->has_tag('extra_info')) {
124                 $had_tag++;
125                 ok (($an->get_tag_values('extra_info'))[0], "contig extra\ninfo\n");
126         }
127         elsif ($an->has_tag('comment')){
128                 $had_tag++;
129                 ok (($an->get_tag_values('comment'))[0], "contig tag\ncomment\n");
130         }
132 ok $had_tag, 2;