File: t180ncbi_taxonomy.t

package info (click to toggle)
libgo-perl 0.15-10
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 8,112 kB
  • sloc: perl: 13,147; sh: 21; makefile: 7
file content (64 lines) | stat: -rw-r--r-- 1,532 bytes parent folder | download | duplicates (8)
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
#!/usr/local/bin/perl -w

use lib '.';
use constant NUMTESTS => 4;
BEGIN {
    eval { require Test; };
    use Test;    
    plan tests => NUMTESTS;
}
# All tests must be run from the software directory;
# make sure we are getting the modules from here:
use strict;
use GO::Parser;

# ----- REQUIREMENTS -----

# ncbi_taxonomy roundtrips
# this test involves class properties

# ------------------------

if (1) {
    my $f = './t/data/sample.ncbi_taxonomy';
    my $f2 = cvt($f,'ncbi_taxonomy','obo');

    # some taxon terms contain {} - test that escaping of these works
    open(F,$f2) || die;
    my $matched;
    while (<F>) {
        # ID 21 has a fake {...} entry
        if (/\\\{test\\\}/) {
            $matched=1;
            last;
        }
    }
    ok($matched);
    
    my $parser = new GO::Parser;
    $parser->parse($f2);
    my $obo = $parser->handler->stag;
    ok($obo->get('header/synonymtypedef'));
    ok($obo->get('term/synonym/@/synonym_type'));
    my @terms = $obo->get_term;
    my ($t) = grep {$_->sget_id eq 'NCBITaxon:21'} @terms;
    # some taxon terms contain {} - test that escaping of these works
    print $t->get_name,"\n";
    ok($t->get_name eq 'Phenylobacterium immobile {test}');
}

exit 0;

sub cvt {
    my $f = shift;
    my ($from, $to) = @_;
    print "$f from:$from to:$to\n";

    my $parser = new GO::Parser ({format=>$from,
				  handler=>$to});
    my $outf = "$f.$to";
    unlink $outf if -f $outf;
    $parser->handler->file($outf);
    $parser->parse($f);
    return $outf;
}