Commit 5b8f4f3d authored by janosch's avatar janosch

Initial commit

parents
This diff is collapsed.
<?xml version="1.0" ?>
<project name="GefPrimerPlugin" 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"/>
<property name="newPluginPackagePath" value="de/mpicbg/gef/extractannotationlist"/>
<property name="oldPluginName" value="GefPrimerPlugin"/>
<property name="oldPluginPackageName" value="de.mpicbg.gef"/>
<property name="oldPluginPackagePath" value="de/mpicbg/gef"/>
<!--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.GefPrimerPlugin
# This is the short name for your plugin. It is used
# to name the gplugin file for distribution.
short-plugin-name=GefPrimerPlugin
\ No newline at end of file
package de.mpicbg.gef;
import com.biomatters.geneious.publicapi.components.Dialogs;
import com.biomatters.geneious.publicapi.databaseservice.DatabaseServiceException;
import com.biomatters.geneious.publicapi.documents.AnnotatedPluginDocument;
import com.biomatters.geneious.publicapi.documents.sequence.SequenceAnnotation;
import com.biomatters.geneious.publicapi.documents.sequence.SequenceDocument;
import com.biomatters.geneious.publicapi.plugin.*;
import jebl.util.ProgressListener;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
/**
* Created by Stephan Janosch on 17/11/17.
*/
public class GefPrimerOperation extends DocumentOperation {
@Override
public GeneiousActionOptions getActionOptions() {
GeneiousActionOptions actionOptions = new GeneiousActionOptions("Create Primers around Annotation", "Generate Primers around Annotation", null, GeneiousActionOptions.Category.None);
actionOptions.setMainMenuLocation(GeneiousActionOptions.MainMenu.Sequence);
actionOptions.setInMainToolbar(false);
return actionOptions;
}
@Override
public String getHelp() {
return "";
}
@Override
public DocumentSelectionSignature[] getSelectionSignatures() {
DocumentSelectionSignature sequenceSelSig = new DocumentSelectionSignature(SequenceDocument.class, 1, 100);
return new DocumentSelectionSignature[]{sequenceSelSig};
}
@Override
public void performOperation(AnnotatedPluginDocument[] annotatedDocuments, ProgressListener progressListener, Options options, SequenceSelection sequenceSelection, OperationCallback callback) throws DocumentOperationException {
String tagType = options.getValueAsString("tagType");
int i = 0;
for (AnnotatedPluginDocument document : annotatedDocuments) {
i++;
progressListener.setProgress(i, annotatedDocuments.length);
SequenceDocument sequenceDocument = (SequenceDocument) document.getDocument();
//find the tag
SequenceAnnotation tagAnnotation = null;
for (SequenceAnnotation annotation : sequenceDocument.getSequenceAnnotations()) {
if (tagAnnotation == null && annotation.getType().equalsIgnoreCase(tagType))
tagAnnotation = annotation;
else if (annotation.getType().equalsIgnoreCase(tagType))
throw new DocumentOperationException("found more that one tag in: " + document.getName());
}
if (tagAnnotation == null)
throw new DocumentOperationException("found no tag in: " + document.getName());
String fromPosition = String.valueOf(tagAnnotation.getInterval().getMinimumIndex());
String toPosition = String.valueOf(tagAnnotation.getInterval().getMaximumIndex());
DocumentOperation primerOperation = PluginUtilities.getDocumentOperation("Operation_com.biomatters.plugins.primerDesign.DesignAnnotationGenerator");
Options primerOperationOptions = primerOperation.getOptions(document);
// System.out.println(primerOperationOptions.getDescriptionAndState());
// System.out.println("Available Options: " + primerOperationOptions.getNamesAndValues(true));
primerOperationOptions.setStringValue("taskOptions.chooser", "designNewOptions");
primerOperationOptions.setStringValue("taskOptions.designNewOptions.oligosToPickOptions.forwardOption", "true");
primerOperationOptions.setStringValue("taskOptions.designNewOptions.oligosToPickOptions.reverseOption", "true");
primerOperationOptions.setStringValue("taskOptions.designNewOptions.oligosToPickOptions.probeOption", "false");
primerOperationOptions.setStringValue("panelForRegionType.designRegionTypeOption", "genericOptionValue");
primerOperationOptions.setStringValue("panelForRegionType.genericRegionOptions.enableIncludedRegionOption", "false");
primerOperationOptions.setStringValue("panelForRegionType.genericRegionOptions.enableTargetRegionOption", "true");
primerOperationOptions.setStringValue("panelForRegionType.genericRegionOptions.targetRegionFromOption", fromPosition);
primerOperationOptions.setStringValue("panelForRegionType.genericRegionOptions.targetRegionToOption", toPosition);
primerOperationOptions.setStringValue("panelForRegionType.genericRegionOptions.enableProductSizeOption", "true");
primerOperationOptions.setStringValue("panelForRegionType.genericRegionOptions.productSizeFromOption", options.getValueAsString("productSizeFromOption"));
primerOperationOptions.setStringValue("panelForRegionType.genericRegionOptions.productSizeToOption", options.getValueAsString("productSizeToOption"));
primerOperationOptions.setStringValue("panelForRegionType.genericRegionOptions.enableOptimalProductSizeOption", "false");
primerOperationOptions.setStringValue("panelForRegionType.genericRegionOptions.numPairsOption", "1");
try {
callback.setSubFolder("primed sequences");
} catch (DatabaseServiceException e) {
e.printStackTrace();
}
primerOperation.performOperation(new AnnotatedPluginDocument[]{document}, ProgressListener.EMPTY, primerOperationOptions, sequenceSelection, callback);
}
}
@Override
public Options getOptions(DocumentOperationInput operationInput) throws DocumentOperationException {
Options options = new Options(getClass());
options.addLabel("select annotation type for tag: ");
Options.OptionValue preselectedTag = null;
List<String> tagTypeList = new LinkedList<String>();
for (AnnotatedPluginDocument doc : operationInput.getInputDocumentsList()) {
SequenceDocument sequenceDocument = null;
if (doc.getDocument() instanceof SequenceDocument) {
sequenceDocument = (SequenceDocument) doc.getDocument();
}
if (sequenceDocument == null)
continue;
for (SequenceAnnotation annotation : sequenceDocument.getSequenceAnnotations()) {
String annoType = annotation.getType().toLowerCase();
if (!tagTypeList.contains(annoType) && annoType != null && !annoType.isEmpty())
tagTypeList.add(annoType);
}
}
if (tagTypeList.isEmpty())
throw new DocumentOperationException("no annotations found");
final Options.OptionValue[] optionValues = new Options.OptionValue[tagTypeList.size()];
int i = 0;
for (String tagTypeString : tagTypeList) {
Options.OptionValue value = new Options.OptionValue(tagTypeString, tagTypeString);
optionValues[i] = value;
if (tagTypeString.equalsIgnoreCase("tag"))
preselectedTag = optionValues[i];
i++;
}
options.addComboBoxOption("tagType", "select annotation type for tag", optionValues, preselectedTag);
options.addIntegerOption("productSizeFromOption", "product size from", 1000);
options.addIntegerOption("productSizeToOption", "product size to", 3000);
return options;
}
}
package de.mpicbg.gef;
import com.biomatters.geneious.publicapi.plugin.DocumentOperation;
import com.biomatters.geneious.publicapi.plugin.GeneiousPlugin;
/**
* Created by Stephan Janosch on 31/08/17.
* orcid.org/0000-0002-2401-6862
*/
public class GefPrimerPlugin extends GeneiousPlugin {
@Override
public String getName() {
return "GEF Primer Plugin";
}
@Override
public String getDescription() {
return "Create 1 primer pair around an annotation within selectable distance";
}
@Override
public String getHelp() {
return "Select multiple sequences and the plugin creates sequence selections";
}
@Override
public String getAuthors() {
return "Stephan Janosch";
}
@Override
public String getVersion() {
return "0.0.1";
}
@Override
public String getMinimumApiVersion() {
return "4.700";
}
@Override
public int getMaximumApiVersion() {
return 4;
}
@Override
public DocumentOperation[] getDocumentOperations() {
return new DocumentOperation[]{new GefPrimerOperation()};
}
}
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