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

Annotation of /FigKernelScripts/server_paper_example3.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.5 - (view) (download) (as text)

1 : overbeek 1.1 use strict;
2 :     use SAPserver;
3 : disz 1.5 use Data::Dumper;
4 : overbeek 1.1
5 :     my ($geneID,$max_distance);
6 :     my $usage = "usage: server_paper_example3 GeneID MaxDistance";
7 :     (
8 :     ($geneID = shift @ARGV) &&
9 :     ($max_distance = shift @ARGV)
10 :     )
11 :     || die $usage;
12 :    
13 :     my $sapObject = SAPserver->new();
14 :     my $geneLocH = $sapObject->fid_locations(-ids => [$geneID]);
15 : parrello 1.2 my $geneLoc = $geneLocH->{$geneID}->[0];
16 : overbeek 1.1 if ($geneLoc =~ /^(\S+)_(\d+)([+-])(\d+)/) # retrieve an encoded location
17 :     {
18 :     my($contig,$beg,$strand,$length) = ($1,$2,$3,$4);
19 : parrello 1.2 my ($left,$right);
20 : overbeek 1.1 if ($strand eq "+")
21 :     {
22 : parrello 1.2 ($left,$right) = ($beg, $beg + ($length-1));
23 : overbeek 1.1 }
24 :     else
25 :     {
26 : parrello 1.2 ($left,$right) = ($beg, $beg - ($length-1));
27 : overbeek 1.1 }
28 :     my $paddedLeft = ($left > $max_distance) ? $left - $max_distance : 1;
29 :     my $paddedRight = $right + $max_distance;
30 :     my $sz = ($paddedRight + 1) - $paddedLeft;
31 :     my $region = $contig . "_" . $paddedLeft . "+" . $sz;
32 : parrello 1.4 my $genesInRegionH = $sapObject->genes_in_region(-locations => [$region],
33 :     -includeLocation => 1);
34 : overbeek 1.1 my $genesInRegion = $genesInRegionH->{$region};
35 : disz 1.5 foreach my $geneID2 (keys(%$genesInRegion)) {
36 :     my $location = $genesInRegion->{$geneID2};
37 : parrello 1.3 $location =~ /^(\S+)_(\d+)([+-])(\d+)/;
38 :     print "$geneID2\t$1\t$2\t$3\t$4\n";
39 : overbeek 1.1 }
40 : parrello 1.4 }

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3