[Bio] / Sprout / SapServerTest.pl Repository:
ViewVC logotype

View of /Sprout/SapServerTest.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.4 - (download) (as text) (annotate)
Tue May 20 18:15:09 2014 UTC (4 years, 11 months ago) by parrello
Branch: MAIN
CVS Tags: rast_rel_2014_0912, rast_rel_2014_0729, HEAD
Changes since 1.3: +1 -1 lines
CDMI and Sprout load fixes. Locations fixes.

### Test program for Ross's project.

use strict;
use SeedUtils;
use SAPserver;
use Sapling;

    my $sapObject;
    if ($ENV{SAS_SERVER} eq 'localhost') {
        my $sap = Sapling->new(dbName => 'pubseed_sapling_14', dbhost => 'localhost', port => 3399);
#        my $sap = Sapling->new(dbName => 'pseed_sapling_10', dbhost => 'localhost', port => 3333);
        $sapObject = SAPserver->new(sapDB => $sap, url => 'localhost');
    } else {
        $sapObject = SAPserver->new();
    }
    my $methods = $sapObject->methods();
    print join(", ", @$methods) . "\n";
    my $genomeH = $sapObject->all_genomes();
    for my $genome (sort keys %$genomeH) {
    	print "$genome: $genomeH->{$genome}\n";
    }
    my $genome1 = $ARGV[0];
    warn "Asking for features of $genome1.\n";
    my $pegHash = $sapObject->all_features(-ids => $genome1, -type => 'peg');
    warn "Got pegs OK.\n";
    my @pegs = sort { SeedUtils::by_fig_id($a,$b) } @{$pegHash->{$genome1}};
    undef $pegHash;
    my $functions = $sapObject->ids_to_functions(-ids => \@pegs);
    warn "Got functions.\n";
    my $dna = $sapObject->ids_to_sequences(-ids => \@pegs);
    warn "Got DNA.\n";
    for my $fid (@pegs) {
        print "$fid is $functions->{$fid}: $dna->{$fid}\n";
    }
    my @smallFidList = @pegs[10..50];
    my $aliasHash = $sapObject->equiv_sequence_ids(-ids => \@smallFidList, -precise => 1);
    for my $fid (@smallFidList) {
        my $aliases = $aliasHash->{$fid};
        if (! defined $aliases) {
            print "$fid not found by alias search.\n";
        } elsif (! scalar(@$aliases)) {
            print "$fid has no aliases.\n";
        } else {
            print "$fid aliases are " . join(", ", @$aliases) . "\n";
        }
    }
    my $contigHash = $sapObject->genome_contigs(-ids => $genome1);
    my $contigs = $contigHash->{$genome1};
    warn "Got contigs.\n";
    my $lengthHash = $sapObject->contig_lengths(-ids => $contigs);
    my $dnaHash = $sapObject->contig_sequences(-ids => $contigs);
    for my $contig (@$contigs) {
        $dna = $dnaHash->{$contig};
        print "DNA length test for $contig is " . length($dna) . " vs $lengthHash->{$contig}.\n";
    }

1;

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3