[Bio] / FigKernelScripts / server_paper_example3.pl Repository:
ViewVC logotype

View of /FigKernelScripts/server_paper_example3.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.5 - (download) (as text) (annotate)
Thu Dec 10 21:41:07 2009 UTC (9 years, 11 months ago) by disz
Branch: MAIN
CVS Tags: mgrast_dev_08112011, mgrast_dev_08022011, rast_rel_2014_0912, myrast_rel40, mgrast_dev_05262011, mgrast_dev_04082011, rast_rel_2010_0928, mgrast_version_3_2, mgrast_dev_12152011, mgrast_dev_06072011, rast_rel_2010_0526, rast_rel_2014_0729, mgrast_dev_02212011, rast_rel_2010_1206, mgrast_release_3_0, mgrast_dev_03252011, rast_rel_2010_0118, rast_rel_2011_0119, mgrast_release_3_0_4, mgrast_release_3_0_2, mgrast_release_3_0_3, mgrast_release_3_0_1, mgrast_dev_03312011, mgrast_release_3_1_2, mgrast_release_3_1_1, mgrast_release_3_1_0, mgrast_dev_04132011, mgrast_dev_04012011, rast_rel_2010_0827, myrast_33, rast_rel_2011_0928, mgrast_dev_04052011, mgrast_dev_02222011, mgrast_dev_10262011, HEAD
Changes since 1.4: +3 -2 lines
converted to new SAP server

use strict;
use SAPserver;
use Data::Dumper;

my ($geneID,$max_distance);
my $usage = "usage: server_paper_example3 GeneID MaxDistance";
(
 ($geneID       = shift @ARGV) &&
 ($max_distance = shift @ARGV)
 )
    || die $usage;

my $sapObject = SAPserver->new();
my $geneLocH  = $sapObject->fid_locations(-ids => [$geneID]);
my $geneLoc   = $geneLocH->{$geneID}->[0];
if ($geneLoc =~ /^(\S+)_(\d+)([+-])(\d+)/)  # retrieve an encoded location
{
    my($contig,$beg,$strand,$length) = ($1,$2,$3,$4);
    my ($left,$right);
    if ($strand eq "+")
    {
	($left,$right) = ($beg, $beg + ($length-1));
    }
    else
    {
	($left,$right) = ($beg, $beg - ($length-1));
    }
    my $paddedLeft      = ($left > $max_distance) ? $left  - $max_distance : 1;
    my $paddedRight     = $right + $max_distance;
    my $sz              = ($paddedRight + 1) - $paddedLeft;
    my $region          = $contig . "_" . $paddedLeft . "+" . $sz;
    my $genesInRegionH  = $sapObject->genes_in_region(-locations => [$region],
                                                      -includeLocation => 1);
    my $genesInRegion   = $genesInRegionH->{$region};
    foreach my $geneID2 (keys(%$genesInRegion)) {
        my $location = $genesInRegion->{$geneID2};
        $location =~ /^(\S+)_(\d+)([+-])(\d+)/;
	print "$geneID2\t$1\t$2\t$3\t$4\n";
    }
}

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3