Details
-
Type: New Feature
-
Status: Open
-
Priority: Major
-
Resolution: Unresolved
-
Affects Version/s: None
-
Fix Version/s: None
-
Component/s: Dev and Dep, Scriptable API
-
Labels:None
Description
The groovy console in Jalview is based on the scripting model introduced pre groovy 1.7 - which did not allow dynamic import of new code.
Grapes allow new classes to be imported by a groovy script e.g. from a maven or OSGi repository, using tags like "@Grab ('org.codehaus.groovy.modules.http-builder:http-builder:0.5.2')"
Jalview's groovy console currently doesn't support these tags. It parses them, but classes are not dynamically retrieved. Ideally, we'd want the user to be able to import the following into the console and have it execute (taken from https://gist.github.com/3798887 - quick and dirty ensembl api with groovy - courtesy of @tim_yates):
@Grab( 'org.codehaus.groovy.modules.http-builder:http-builder:0.5.2' )
import groovyx.net.http.RESTClient
// A connection to ensembl
def ensembl = new RESTClient( 'http://beta.rest.ensembl.org/' )
// Get a list of species
def spec = ensembl.get( path:'info/species',
query:[ 'content-type':'application/json' ] )
// Find the species with "baker's yeast" as an alias
String species = spec.data.species.findResult { "baker's yeast" in it.aliases ? it.name : null }
// Get all the assemblies for this species
def assembly = ensembl.get( path:"assembly/info/$species",
query:[ 'content-type':'application/json' ] )
List assemblies = assembly.data.top_level_seq_region_names
// For each assembly, try and get the assembly info for it
// (Currently the API fails for non-chromosomal assemblies)
List chromosomes = assemblies.findAll {
// Need to limit to 3 requests per second (max)
Thread.sleep( 400 )
print '.'
try {
ensembl.get( path:"assembly/info/$species/$it", query:[ 'content-type':'application/json' ] )
} catch( e ) { false }
}
println "\n$species has chromosomes $chromosomes"
Grapes allow new classes to be imported by a groovy script e.g. from a maven or OSGi repository, using tags like "@Grab ('org.codehaus.groovy.modules.http-builder:http-builder:0.5.2')"
Jalview's groovy console currently doesn't support these tags. It parses them, but classes are not dynamically retrieved. Ideally, we'd want the user to be able to import the following into the console and have it execute (taken from https://gist.github.com/3798887 - quick and dirty ensembl api with groovy - courtesy of @tim_yates):
@Grab( 'org.codehaus.groovy.modules.http-builder:http-builder:0.5.2' )
import groovyx.net.http.RESTClient
// A connection to ensembl
def ensembl = new RESTClient( 'http://beta.rest.ensembl.org/' )
// Get a list of species
def spec = ensembl.get( path:'info/species',
query:[ 'content-type':'application/json' ] )
// Find the species with "baker's yeast" as an alias
String species = spec.data.species.findResult { "baker's yeast" in it.aliases ? it.name : null }
// Get all the assemblies for this species
def assembly = ensembl.get( path:"assembly/info/$species",
query:[ 'content-type':'application/json' ] )
List assemblies = assembly.data.top_level_seq_region_names
// For each assembly, try and get the assembly info for it
// (Currently the API fails for non-chromosomal assemblies)
List chromosomes = assemblies.findAll {
// Need to limit to 3 requests per second (max)
Thread.sleep( 400 )
print '.'
try {
ensembl.get( path:"assembly/info/$species/$it", query:[ 'content-type':'application/json' ] )
} catch( e ) { false }
}
println "\n$species has chromosomes $chromosomes"
Attachments
Issue Links
- depends on
-
JAL-2074 update groovy console to V2.x
- Closed