Bio-WebService-LANL-SequenceLocator

 view release on metacpan or  search on metacpan

share/about.html  view on Meta::CPAN

               "1",
               "45"
            ],
            "protein_translation" : "SLYNTVATLYCVHQR"
         }
      ]
   }
]
</pre>
<pre>
curl -X POST https://indra.mullins.microbiol.washington.edu/locate-sequence/within/hiv \
     --data base='amino acid' \
     --data sequence=MGGDMKDNW
</pre>
<pre>
curl -X POST https://indra.mullins.microbiol.washington.edu/locate-sequence/within/hiv \
     --form base=nucleotide \
     --form fasta=@<i>/path/to/your/input.fa</i>
</pre>

<a name="perl"></a>
<h3>Perl</h3>
<h4>Directly using <a href="https://metacpan.org/pod/Bio::WebService::LANL::SequenceLocator"><code>Bio::WebService::LANL::SequenceLocator</code></a></h4>
<pre>
#!/usr/bin/env perl
#
# First install the library:
#   cpan -i Bio::WebService::LANL::SequenceLocator
# 
use strict;
use warnings;
use Bio::WebService::LANL::SequenceLocator;

my $locator = Bio::WebService::LANL::SequenceLocator->new(
    agent_string => 'Your Organization - you@example.com',
);

my @sequences = $locator->find([
    "agcaatcagatggtcagccaaaattgccctatagtgcagaacatcc"
   ."aggggcaagtggtacatcaggccatatcacctagaactttaaatgca",
]);
</pre>

<h4>Through our web API</h4>
<pre>
#!/usr/bin/env perl
use strict;
use warnings;

use JSON qw< decode_json >;
use LWP::UserAgent;

my $agent    = LWP::UserAgent->new( agent => 'you@example.com' );
my $response = $agent->post(
    "https://indra.mullins.microbiol.washington.edu/locate-sequence/within/hiv" => [
        sequence => "TCATTATATAATACAGTAGCAACCCTCTATTGTGTGCATCAAAGG",
    ],
);
unless ($response->is_success) {
    die "Request failed: ", $response->status_line, "\n",
        $response->decoded_content;
}
my $results = decode_json( $response->decoded_content );

# $results is now an array ref, like the JSON above
print $results->[0]{polyprotein}, "\n";
</pre>

<a name="python"></a>
<h3>Python</h3>
<pre>
#!/usr/bin/env python2
from urllib2 import Request, urlopen, URLError
from urllib  import urlencode
import json

request = Request('https://indra.microbiol.washington.edu/locate-sequence/within/hiv')
data = urlencode({
    'sequence': [
        'SLYNTVAVLYYVHQR',
        'TCATTATATAATACAGTAGCAACCCTCTATTGTGTGCATCAAAGG'
    ]
}, True);

try:
    response = urlopen(request, data)
    text     = response.read()
    results  = json.loads(text)
except URLError, e:
    print 'Request failed: ', e
except ValueError, e:
    print 'Decoding JSON failed: ', e
finally:
    if results == None:
        exit(1)

print results
</pre>

<a name="R"></a>
<h3>R</h3>
<pre>
library("RCurl")
library("rjson")

results = tryCatch(
  fromJSON(
    postForm(
      "https://indra.mullins.microbiol.washington.edu/locate-sequence/within/hiv",
      sequence="SLYNTVAVLYYVHQR",
      sequence="TCATTATATAATACAGTAGCAACCCTCTATTGTGTGCATCAAAGG")),
  HTTPError = function(e) cat("Error making request: ", e$message),
  error = function(e) cat("Error decoding JSON"))

print(lapply(results, function(s) s$genome_start))
</pre>
                </div>
            </div>
        </div>
    </body>
</html>



( run in 0.517 second using v1.01-cache-2.11-cpan-39bf76dae61 )