-
Notifications
You must be signed in to change notification settings - Fork 0
CyniMetricTutorial
#How to create a Cyni Metric
##Introduction
In order to help app developers, we provide a Cyni Metric sample, which contains a "HelloWorld" implementation of a Cyni Metric. This sample will serve as a starting point or template for new app developers. Cyni sample code can be used by following these steps:
- Check out the cyni sample projects from our Github repository with this command:
git clone git://github.com/schwikowskilab/cyni-samples.git
- Go the ''cyni-metric-sample'' directory and compile it with
mvn clean install
Next sections describe each file that needs to be created to produce a Cyni Metric App.
##Pom File
Here are the main lines to modify in the pom.xml file. The fields bundle.symbolicName and bundle.namespace properties should be modified according to new app directory configuration. Tags groupId and artifactId also have to be modified. Finally, version tag should be set to developer requirements.
<properties>
<bundle.symbolicName>cyni-metric-sample</bundle.symbolicName>
<bundle.namespace>fr.systemsbiology.cyniSampleMetric.internal</bundle.namespace>
<cytoscape.api.version>3.1.0</cytoscape.api.version>
<cyni.api.version>1.0.0</cyni.api.version>
<maven-bundle-plugin.version>2.3.4</maven-bundle-plugin.version>
<osgi.api.version>4.2.0</osgi.api.version>
</properties>
<groupId>fr.systemsbiology.cyniSampleMetric</groupId>
<artifactId>cyniSampleMetric</artifactId>
<packaging>bundle</packaging>
<name>${bundle.symbolicName}</name>
<version>3.0.0-alpha1-SNAPSHOT</version>
##CyActivator
In this file, any Cyni Metric implemented needs to be registered. These two lines do the work. First, we create the object for the new Cyni Metric and then we register it to make it available by the Cyni Metric Manager.
//Define new Cyni Metric
CyniSampleMetric sample = new CyniSampleMetric();
//Register new Cyni Algorithm
registerService(bc,sample,CyCyniMetric.class, new Properties());
##CyniSampleMetric
The constructor of this class has two input parameters. The two names of the metric, the one used internally and the one to be displayed. Then, the tags that this metric support are added by the function addTag. These tags are strings and in the sample, the supported tags are filled by Cyni default tags but any string could be added too.
public CyniSampleMetric() {
super("sampleMetric.cyni","Cyni Sample Metric");
addTag(CyniMetricTypes.INPUT_NUMBERS.toString());
addTag(CyniMetricTypes.CORRELATION_METRIC.toString());
}
GetMetric method should contain the implementation of the metric. The dots should be replaced with the actual implementation, which should calculate a value that finally will be saved in the variable result. All data required to perform a measure is passed through CyniTable's.
public Double getMetric(CyniTable table1, CyniTable table2, int indexBase, List<Integer> indexToCompare) {
double result = 0.0;
int index2 = indexToCompare.get(0);
.........................................
return result;
}
- Home
- [Cyni Architecture ] (CyniArchitecture)
- Cyni Algorithm Tutorial 1
- Cyni Algorithm Tutorial 2
- Cyni Metric Tutorial