~ubuntu-branches/ubuntu/trusty/bioperl/trusty

« back to all changes in this revision

Viewing changes to t/SeqIO/genbank.t

  • Committer: Package Import Robot
  • Author(s): Charles Plessy
  • Date: 2013-09-22 13:39:48 UTC
  • mfrom: (3.1.11 sid)
  • Revision ID: package-import@ubuntu.com-20130922133948-c6z62zegjyp7ztou
Tags: 1.6.922-1
* New upstream release.
* Replaces and Breaks grinder (<< 0.5.3-3~) because of overlaping contents.
  Closes: #722910
* Stop Replacing and Breaking bioperl ( << 1.6.9 ): not needed anymore. 

Show diffs side-by-side

added added

removed removed

Lines of Context:
6
6
BEGIN {
7
7
    use lib '.';
8
8
        use Bio::Root::Test;
9
 
        
10
 
        test_begin(-tests => 272 );
11
 
        
 
9
        test_begin(-tests => 282 );
12
10
    use_ok('Bio::SeqIO::genbank');
13
11
}
14
12
 
392
390
 
393
391
foreach my $in ('BK000016-tpa.gbk', 'ay116458.gb', 'ay149291.gb', 'NC_006346.gb', 'ay007676.gb', 'dq519393.gb') {
394
392
    my $infile =  test_input_file($in);
395
 
    
 
393
 
396
394
    $str = Bio::SeqIO->new(-format =>'genbank',
397
395
                          -verbose => $verbose,
398
396
                          -file => $infile);
399
397
    $seq = $str->next_seq;
400
 
    
 
398
 
401
399
    $out = Bio::SeqIO->new(-file => ">$outfile", -format => 'genbank');
402
400
    $out->write_seq($seq);
403
401
    $out->close();
404
 
    
 
402
 
405
403
    open (IN, $infile);
406
404
    my @in = <IN>;
407
405
    close(IN);
409
407
    my $line = 0;
410
408
    my $check = 0;
411
409
    my $is = 1;
412
 
    
 
410
 
413
411
    FILECHECK:
414
412
    while (my $result = <RESULT>) {
415
413
        if ($result =~ /^KEYWORDS/) {
422
420
        }
423
421
 
424
422
        if ($check) {
425
 
            
 
423
 
426
424
            # end periods don't count (not all input files have them)
427
425
            $result =~ s{\.$}{};
428
426
            $in[$line] =~ s{\.$}{};
429
 
            
 
427
 
430
428
            if ($result ne $in[$line]) {
431
429
                $is = 0;
432
430
                last;
434
432
        }
435
433
    } continue { $line++ }
436
434
    close(RESULT);
437
 
    
 
435
 
438
436
    ok $is, $in;
439
437
}
440
438
 
481
479
                }
482
480
                    ok ( $parts[1], "$parts[0]" );
483
481
            }
484
 
                
 
482
 
485
483
        }
486
484
    }
487
485
}
489
487
is($ct, 46);
490
488
 
491
489
# bug 2195
492
 
    
 
490
 
493
491
$str = Bio::SeqIO->new(-format =>'genbank',
494
492
                      -verbose => $verbose,
495
493
                      -file => test_input_file('AF305198.gb')
504
502
   'Firmicutes, Bacteria', 'Bug 2195');
505
503
 
506
504
# bug 2569, PROJECT line support, read and write, round-tripping
507
 
    
 
505
 
508
506
$str = Bio::SeqIO->new(-format =>'genbank',
509
507
                      -verbose => $verbose,
510
508
                      -file => test_input_file('NC_008536.gb'));
573
571
 
574
572
#bug 2982 embl/genbank contig handling
575
573
 
576
 
$ast = Bio::SeqIO->new( -file => test_input_file('bug2982.gb'), 
 
574
$ast = Bio::SeqIO->new( -file => test_input_file('bug2982.gb'),
577
575
                        -format => 'genbank' );
578
576
 
579
577
$seq = $ast->next_seq;
581
579
ok my @ctg = $seq->annotation->get_Annotations('contig');
582
580
like $ctg[0]->value, qr/join\(.*?gap.*?complement/;
583
581
 
 
582
# write_seq() and FTHelper duplicate specific tags, need to check a round-trip
 
583
$ast = Bio::SeqIO->new(-format => 'genbank' ,
 
584
                       -verbose => $verbose,
 
585
                       -file => test_input_file('singlescore.gbk'));
 
586
$as = $ast->next_seq();
 
587
($cds) = grep { $_->primary_tag eq 'CDS' } $as->get_SeqFeatures();
 
588
my @notes = $cds->get_tag_values('note');
 
589
is(scalar @notes, 2);
 
590
$testfile = test_output_file();
 
591
$out = Bio::SeqIO->new(-file => ">$testfile",
 
592
                       -format => 'genbank');
 
593
$out->write_seq($as);
 
594
$out->close();
 
595
$ast = Bio::SeqIO->new(-format => 'genbank' ,
 
596
                       -verbose => $verbose,
 
597
                       -file => $testfile );
 
598
$as = $ast->next_seq;
 
599
($cds) = grep { $_->primary_tag eq 'CDS' } $as->get_SeqFeatures();
 
600
@notes = $cds->get_tag_values('note');
 
601
is(scalar @notes, 2);
 
602
 
 
603
 
 
604
#bug 3375
 
605
my $in = Bio::SeqIO->new(-format => 'genbank',
 
606
                        -file => test_input_file('NC_002058_multDBLINK_bug3375.gb'));
 
607
$seq = $in->next_seq();     # should not throw a warning now
 
608
@dblinks = $seq->annotation->get_Annotations('dblink');    # contains 5 dblink references
 
609
# testing DBLINK      BioProject: PRJNA15288
 
610
is($dblinks[0]->database, 'BioProject', 'bug3375 database is BioProject');
 
611
is($dblinks[0]->primary_id, 'PRJNA15288', 'bug3375 primary_id is PRJNA15288');
 
612
# testing DBLINK      Project:100,200,300
 
613
is($dblinks[3]->database, 'Project');
 
614
is($dblinks[3]->primary_id, '300');
 
615
# testing DBLINK      NC_002058.3
 
616
is($dblinks[4]->database, 'GenBank');
 
617
is($dblinks[4]->primary_id, 'NC_002058');
 
618
is($dblinks[4]->version, '3');
 
619
 
 
620
# long labels handled
 
621
{
 
622
    # Create sequence with feature with a long label qualifier
 
623
    my $seq=Bio::Seq->new(-seq  => 'actg',
 
624
                          -id   => 'abacab');
 
625
    my $feature=Bio::SeqFeature::Generic->new(-primary=>'CDS', -start=>1, -end=>4);
 
626
    my $label='1 2 3 4 5 6 7 8 9 a b c d e f g h i j k l m n o p q r';
 
627
    $feature->add_tag_value(label=>$label);
 
628
    $seq->add_SeqFeature($feature);
 
629
 
 
630
    # Write genbank
 
631
    my $string;
 
632
    open(my $str_fh, '>', \$string) || skip("Can't open string, skipping", 2);
 
633
    my $out=Bio::SeqIO->new(-format=>'genbank', -fh => $str_fh);
 
634
    $out->write_seq($seq);
 
635
 
 
636
    # Read genbank
 
637
    my $in=Bio::SeqIO->new(-format=>'genbank', -string => $string);
 
638
    my $genbank=$in->next_seq;
 
639
    my ($read_feature)=$genbank->get_SeqFeatures;
 
640
    my ($read_label)=$read_feature->get_tag_values('label');
 
641
    is($read_label, $label, 'Label is the same');
 
642
}