Bio-KBase
view release on metacpan or search on metacpan
lib/Bio/KBase/InvocationService/InvocationServiceImpl.pm view on Meta::CPAN
{
die "Invalid path $dir";
}
my @dirs;
my @files;
my $dh;
opendir($dh, $dir) or die "Cannot open directory: $!";
while (my $file = readdir($dh)) {
next if ($file =~ m/^\./);
my($dev, $ino, $mode, $nlink, $uid, $gid, $rdev, $size, $atime, $mtime, $ctime, $blksize, $blocks) = stat("$dir/$file");
my $date= strftime("%b %d %G %H:%M:%S", localtime($mtime));
if (-f "$dir/$file") {
push @files, { name => $file, full_path => "$fpath/$file", mod_date => $date, size => $size};
} elsif (-d "$dir/$file") {
push @dirs, { name => $file, full_path => "$fpath/$file", mod_date => $date };
}
}
scripts/get_abundance_profile view on Meta::CPAN
use warnings;
use JSON;
use Getopt::Long;
use LWP::UserAgent ;
use HTTP::Request::Common;
use Bio::KBase;
use Data::Dumper;
my $mgid = "mgm4447970.3" ;
my $type = "function";
my $format = 'plain' ;
my $source = 'Subsystems';
my $debug = 0 ;
GetOptions (
'id=s' => \$mgid ,
'type=s' => \$type , # "organism", "function", "feature"
'format=s' => \$format ,
'source=s' => \$source ,
'debug' => \$debug ,
);
if ($mgid =~/^kb\|/){
my $kb = Bio::KBase->new;
my $idserver = $kb->id_server;
my $return = $idserver->kbase_ids_to_external_ids( [ $mgid ]);
$mgid = $return->{$mgid}->[1] ;
}
my $ua = LWP::UserAgent->new;
$ua->agent("KBASE/0.1 ");
# Create a request
my $base_url = "http://dev.metagenomics.anl.gov/api.cgi/" ;
#my $base_url = "http://dunkirk.mcs.anl.gov/~tharriso/mgrast/api.cgi/";
my $url = $base_url . "abundance_profile/".$mgid."?format=".$format."&type=".$type."&source=".$source;
my $req = HTTP::Request->new(GET => "$url");
my $res = $ua->request($req);
if ($res->is_success){
if ($res->header('Content-Type') eq "application/json") {
my $json = JSON->new->allow_nonref;
my $biom = $json->decode( $res->decoded_content );
( run in 3.194 seconds using v1.01-cache-2.11-cpan-5735350b133 )