public interface ScriptConfiguredTool<C>
Here is how a typical Tool is implemented:
First an java interface for the configuration needs to be defined. Here the configuration needs to provide a tolerance and a peptide.
public interface SearchConfiguration {
Tolerance getTolerance();
Peptide getPeptide();
}
The application is implemented as follows
public class MyApp extends ScriptConfiguredTool<SearchConfiguration> {
@Override
public Class<SearchConfiguration> getConfigurationClass() {
return SearchConfiguration.class;
}
@Override
public int run(SearchConfiguration configuration) {
Tolerance tolerance = configuration.getTolerance();
Peptide peptide = configuration.getPeptide();
//Run the search using the tolerance and peptide
return 0;
}
public static void main(String[] args) throws Exception {
File file = new File("/path/to/Config.js");
ScriptConfiguredToolRunner.run(file, new MyApp());
}
}
The javascript script that provides configured objects is:
function getTolerance(){
return new org.expasy.mzjava.core.ms.AbsoluteTolerance(0.2);
}
function getPeptide(){
return org.expasy.mzjava.proteomics.mol.Peptide.parse('CERVILAS');
}
and the same script in groovy:
import org.expasy.mzjava.core.ms.AbsoluteTolerance
import org.expasy.mzjava.proteomics.mol.Peptide
def getTolerance(){
new AbsoluteTolerance(0.2)
}
def getPeptide(){
Peptide.parse("CERVILAS")
}
| Modifier and Type | Method and Description |
|---|---|
Class<C> |
getConfigurationClass()
Returns the interface that the configuration implements
|
int |
run(C configuration)
Execute the tool with the given configuration
|
Copyright © 2016. All Rights Reserved.