Commit 9688c3e3 authored by Stephan Janosch's avatar Stephan Janosch

Initial Commit

parents
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="module" module-name="GeneiousFiles" />
</component>
</module>
GEF Primer Plugin
=================
Goal
----
Creator
-------
Stephan Janosch
janosch@mpi-cbg.de
http://orcid.org/0000-0002-2401-6862
\ No newline at end of file
<?xml version="1.0" ?>
<project name="GefExtractAnnotationListPlugin" default="distribute" basedir="">
<property file="plugin.properties"/>
<property name="build" location="build"/>
<property name="classes" location="classes"/>
<property name="src" location="src"/>
<path id="classpath">
<fileset dir="../../geneiousPlugins/geneious-10.2.3-devkit/examples/GeneiousFiles/lib">
<include name="GeneiousPublicAPI.jar"/>
<include name="jdom.jar"/>
<include name="jebl.jar"/>
</fileset>
</path>
<target name= "distribute" depends="build">
<copy file="${build}/${short-plugin-name}.jar" tofile="${build}/${short-plugin-name}.gplugin"/>
<echo message="Created ${build}/${short-plugin-name}.gplugin"/>
<!--If your plugin consists of a folder you should build it into
a zip file with extension gplugin. See commented example below.
Remove above line and uncomment these to use-->
<!--
<zip zipfile="${build}/${short-plugin-name}.gplugin">
<fileset dir="${build}/${plugin-name}"/>
</zip>
-->
</target>
<target name="build" depends="compile">
<jar jarfile="${build}/${short-plugin-name}.jar">
<fileset dir="${classes}"/>
<fileset dir="">
<include name="plugin.properties"/>
</fileset>
</jar>
<!--build example for folder type plugin. Remove above
lines and uncomment these to use-->
<!--
<jar jarfile="${build}/${short-plugin-name}.jar">
<fileset dir="${classes}"/>
</jar>
<mkdir dir="${build}/${plugin-name}"/>
<copy todir="${build}/${plugin-name}">
<fileset dir="${build}">
<include name="ExtraFiles"/>
<include name="ExtraFiles/*"/>
<include name="${short-plugin-name}.jar"/>
</fileset>
<fileset dir="docs">
<include name="readme.txt"/>
</fileset>
</copy>
-->
</target>
<target name="compile" depends="prepare">
<javac target="1.8" source="1.8" destdir="${classes}" debug="true">
<classpath refid="classpath"/>
<src path="${src}"/>
</javac>
</target>
<target name="prepare">
<mkdir dir="${build}"/>
<mkdir dir="${classes}"/>
</target>
<target name="clean">
<delete dir="${build}"/>
<delete dir="${classes}"/>
</target>
<target name="copyPluginAndRename">
<!-- This task renames this plugin, including source code files and build scripts.
To use it, enter the appropriate values for the first 3 properties and then run it.
The 3rd property value must be identical to the second except with "." replaced with "/" -->
<property name="newPluginName" value="GefExtractAnnotationListPlugin"/>
<property name="newPluginPackageName" value="de.mpicbg.gef.extractannotationlist.extractannotationlist"/>
<property name="newPluginPackagePath" value="de/mpicbg/gef/extractannotationlist/extractannotationlist"/>
<property name="oldPluginName" value="GefExtractAnnotationListPlugin"/>
<property name="oldPluginPackageName" value="de.mpicbg.gef.extractannotationlist"/>
<property name="oldPluginPackagePath" value="de/mpicbg/gef/extractannotationlist"/>
<!--It doesn't appear we can automatically replace "." with "/" in a property in basic ant without relying on the ant-contrib package being installed-->
<property name="destDir" value="../${newPluginName}"/>
<fail message="You must set the newPluginName property in the ant task XML before running this">
<condition><equals arg1="${oldPluginName}" arg2="${newPluginName}"/></condition>
</fail>
<fail message="You must set the newPluginPackageName property in the ant task XML before running this">
<condition><equals arg1="${oldPluginPackageName}" arg2="${newPluginPackageName}"/></condition>
</fail>
<fail message="You must set the newPluginPackagePath property in the ant task XML before running this">
<condition><equals arg1="${oldPluginPackagePath}" arg2="${newPluginPackagePath}"/></condition>
</fail>
<copy todir="${destDir}">
<fileset dir=""/>
</copy>
<replace dir="${destDir}" token="${oldPluginPackageName}" value="${newPluginPackageName}"/>
<replace dir="${destDir}" token="${oldPluginPackagePath}" value="${newPluginPackagePath}"/>
<replace dir="${destDir}" token="${oldPluginName}" value="${newPluginName}"/>
<move todir="${destDir}/src/${newPluginPackagePath}">
<fileset dir="${destDir}/src/${oldPluginPackagePath}"/>
</move>
<move todir="${destDir}/src/${newPluginPackagePath}">
<fileset dir="${destDir}/src/${newPluginPackagePath}"/>
<mapper type="glob" from="${oldPluginName}*.java" to="${newPluginName}*.java"/>
</move>
<move todir="${destDir}">
<fileset dir="${destDir}"/>
<mapper type="glob" from="${oldPluginName}.*" to="${newPluginName}.*"/>
</move>
<!-- edit intellij project files -->
<copy todir="../.ideaBackup" overwrite="true">
<fileset dir="../.idea"/>
</copy>
<copy file="../.idea/modules.xml" tofile="../.idea/modules.xml.new" overwrite="true">
<filterchain>
<tokenfilter>
<replaceregex byline="true" flags="s"
pattern="(.*)${oldPluginName}/${oldPluginName}(.*)${oldPluginName}/${oldPluginName}(.*)$"
replace="\0&#10;\1${newPluginName}/${newPluginName}\2${newPluginName}/${newPluginName}\3"/>
</tokenfilter>
</filterchain>
</copy>
<fixcrlf file="../.idea/modules.xml.new"/>
<move file="../.idea/modules.xml.new" tofile="../.idea/modules.xml" overwrite="true"/>
<copy file="../.idea/runConfigurations/${oldPluginName}__64_bit_.xml" tofile="../.idea/runConfigurations/${newPluginName}__64_bit_.xml" overwrite="true"/>
<replace file="../.idea/runConfigurations/${newPluginName}__64_bit_.xml" token="${oldPluginPackageName}" value="${newPluginPackageName}"/>
<replace file="../.idea/runConfigurations/${newPluginName}__64_bit_.xml" token="${oldPluginName}" value="${newPluginName}"/>
<copy file="../.idea/runConfigurations/${oldPluginName}__32_bit_.xml" tofile="../.idea/runConfigurations/${newPluginName}__32_bit_.xml" overwrite="true"/>
<replace file="../.idea/runConfigurations/${newPluginName}__32_bit_.xml" token="${oldPluginPackageName}" value="${newPluginPackageName}"/>
<replace file="../.idea/runConfigurations/${newPluginName}__32_bit_.xml" token="${oldPluginName}" value="${newPluginName}"/>
</target>
</project>
# This file contains important information about the plugin
# and must be included in the plugin jar file.
# This is the fully qualified name of the main class
# of the plugin you are developing. This is required by
# Geneious to install a plugin.
plugin-name=de.mpicbg.gef.extractannotationlist.GefExtractAnnotationListPlugin
# This is the short name for your plugin. It is used
# to name the gplugin file for distribution.
short-plugin-name=GefExtractAnnotationListPlugin
\ No newline at end of file
package de.mpicbg.gef.extractannotationlist;
import com.biomatters.geneious.publicapi.documents.AnnotatedPluginDocument;
import com.biomatters.geneious.publicapi.documents.sequence.SequenceDocument;
import com.biomatters.geneious.publicapi.plugin.*;
import jebl.util.ProgressListener;
import java.util.*;
/**
* Created by Stephan Janosch on 31/08/17.
* orcid.org/0000-0002-2401-6862
*/
public class GefExtractAnnotationListPlugin extends GeneiousPlugin {
@Override
public String getName() {
return "GEF Extract Features from List";
}
@Override
public String getDescription() {
return "Extracts all features from a sequence which are given in a parameter list.";
}
@Override
public String getHelp() {
return "Extracts all features from a sequence which are given in a parameter list.";
}
@Override
public String getAuthors() {
return "Stephan Janosch";
}
@Override
public String getVersion() {
return "0.0.1";
}
@Override
public String getMinimumApiVersion() {
return "4.0";
}
@Override
public int getMaximumApiVersion() {
return 4;
}
@Override
public DocumentOperation[] getDocumentOperations() {
return new DocumentOperation[]{new DocumentOperation() {
@Override
public GeneiousActionOptions getActionOptions() {
GeneiousActionOptions actionOptions = new GeneiousActionOptions("Extract Features from List", "Extract Features from List", null, GeneiousActionOptions.Category.None);
actionOptions.setMainMenuLocation(GeneiousActionOptions.MainMenu.Sequence);
actionOptions.setInMainToolbar(false);
return actionOptions;
}
@Override
public String getHelp() {
return null;
}
@Override
public DocumentSelectionSignature[] getSelectionSignatures() {
DocumentSelectionSignature sequenceSelSig = new DocumentSelectionSignature(SequenceDocument.class, 1, 100);
return new DocumentSelectionSignature[]{sequenceSelSig};
}
@Override
public List<AnnotatedPluginDocument> performOperation(AnnotatedPluginDocument[] annotatedDocuments, ProgressListener progressListener, Options options) throws DocumentOperationException {
String listOfNames = options.getOption("listOfNames").getValueAsString();
List<String> namesWanted = new LinkedList<>();
final boolean matchPartialNames = ((Options.BooleanOption) options.getOption("matchPartialNames")).getValue();
// final String optionType = options.getOption("type").getValueAsString();
for (String name : listOfNames.split(options.getOption("separator").getValueAsString())) {
namesWanted.add(name.trim());
}
List<AnnotatedPluginDocument> results = new ArrayList<AnnotatedPluginDocument>();
for (String s:namesWanted)
System.out.println(s);
for (AnnotatedPluginDocument doc : annotatedDocuments) {
for (String name : namesWanted) {
DocumentOperation extractionOperation = PluginUtilities.getDocumentOperation("com.biomatters.plugins.extractAnnotations.ExtractAnnotationsOperation");
Options extractionOptions = extractionOperation.getOptions(doc);
// System.out.println(extractionOptions.getNamesAndValues(true));
assert extractionOptions.setStringValue("match", "all");
assert extractionOptions.setStringValue("whatToExtract", "annotatedRegion");
assert extractionOptions.setStringValue("intersecting", "includeContained");
assert extractionOptions.setStringValue("concatenate", "false");
assert extractionOptions.setStringValue("includeIntergenicRegionsOption", "false");
assert extractionOptions.setStringValue("dontMatchTruncated", "false");
assert extractionOptions.setStringValue("extractionContextOptions.includeUpstreamBasesOption", "true");
assert extractionOptions.setStringValue("extractionContextOptions.numUpstreamBasesOption", "10000");
assert extractionOptions.setStringValue("extractionContextOptions.includeDownstreamBasesOption", "true");
assert extractionOptions.setStringValue("extractionContextOptions.numDownstreamBasesOption", "10000");
assert extractionOptions.setStringValue("annotation.0.field", "Annotation name");
assert extractionOptions.setStringValue("annotation.0.condition", "contains");
assert extractionOptions.setStringValue("annotation.0.value", name);
results.addAll(
extractionOperation.performOperation(new AnnotatedPluginDocument[]{doc}, ProgressListener.EMPTY, extractionOptions));
/*
assert extractionOptions.setStringValue("annotation.1.field","Annotation type");
assert extractionOptions.setStringValue("annotation.1.condition","is");
assert extractionOptions.setStringValue("annotation.1.value","optionType");
match: "all"
annotation.0.field: "Annotation type"
annotation.0.condition: "is"
annotation.0.value: ""
whatToExtract: "annotatedRegion" (What to extract:)
intersecting: "includeContained" (Intersecting Annotations:)
concatenate: "false" (Concatenate regions within each sequence)
includeIntergenicRegionsOption: "false" (Include Intergenic Regions)
dontMatchTruncated: "false" (Don't match truncated annotations)
extractionContextOptions.includeUpstreamBasesOption: "false" (Include upstream (5') flanking bases: )
extractionContextOptions.numUpstreamBasesOption: "0"
extractionContextOptions.includeDownstreamBasesOption: "false" (Include downstream (3') flanking bases: )
extractionContextOptions.numDownstreamBasesOption: "0"
*/
}//name
}//doc
return results;
}
@Override
public Options getOptions(DocumentOperationInput operationInput) throws DocumentOperationException {
// DocumentOperation extractionOperation = PluginUtilities.getDocumentOperation("com.biomatters.plugins.extractAnnotations.ExtractAnnotationsOperation");
Options options = new Options(getClass());
// options.addMultipleLineStringOption("boo","boo",extractionOperation.getOptions(operationInput).getNamesAndValues(false),20,false);
options.addMultipleLineStringOption("listOfNames", "Names to Extract:", "", 10, true).setFillHorizontalSpace(true);
options.addStringOption("separator", "Separator:", ",");
// options.addStringOption("type","Type:","CDS");
options.addBooleanOption("matchPartialNames", "Match partial names", false);
return options;
}
}};
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment