Commit 06d7e141 authored by Stephan Janosch's avatar Stephan Janosch

progressbar added, code cleanup, not found stuff shows up

parent ed69a314
name: 'match' label: '' default value: 'all' current value: 'all'
possible values:  all (Match all of the following) ()  any (Match any of the following) ()
name: 'annotation.[0|1|2|...].field' label: '' default value: 'Annotation type' current value: 'Annotation type' possible values: name: 'Annotation type' label: 'Annotation type' name: 'Annotation name' label: 'Annotation name' name: 'Any annotation qualifier' label: 'Any annotation qualifier' name: 'Every annotation qualifier' label: 'Every annotation qualifier' name: 'Annotation track name' label: 'Annotation track name' name: 'Qualifier: note' label: 'Qualifier: note' name: 'Qualifier: organism' label: 'Qualifier: organism' name: 'Qualifier: mol_type' label: 'Qualifier: mol_type' name: 'Qualifier: db_xref' label: 'Qualifier: db_xref' name: 'Qualifier: chromosome' label: 'Qualifier: chromosome' name: 'Qualifier: NCBI Feature Key' label: 'Qualifier: NCBI Feature Key' name: 'Qualifier: gene' label: 'Qualifier: gene' name: 'Qualifier: product' label: 'Qualifier: product' name: 'Qualifier: inference' label: 'Qualifier: inference' name: 'Qualifier: anticodon' label: 'Qualifier: anticodon' name: 'Qualifier: NCBI Join Type' label: 'Qualifier: NCBI Join Type' name: 'Qualifier: gene_synonym' label: 'Qualifier: gene_synonym' name: 'Qualifier: standard_name' label: 'Qualifier: standard_name' name: 'Qualifier: pseudo' label: 'Qualifier: pseudo' name: 'Qualifier: estimated_length' label: 'Qualifier: estimated_length' name: 'Qualifier: gap_type' label: 'Qualifier: gap_type' name: 'Qualifier: transcript_id' label: 'Qualifier: transcript_id' name: 'Qualifier: number' label: 'Qualifier: number' name: 'Qualifier: exception' label: 'Qualifier: exception' name: 'Qualifier: ncRNA_class' label: 'Qualifier: ncRNA_class' name: 'Qualifier: codon_start' label: 'Qualifier: codon_start' name: 'Qualifier: protein_id' label: 'Qualifier: protein_id' name: 'Qualifier: translation' label: 'Qualifier: translation' name: 'Qualifier: transl_except' label: 'Qualifier: transl_except' name: 'Qualifier: EC_number' label: 'Qualifier: EC_number' name: 'Qualifier: Source' label: 'Qualifier: Source' name: 'Qualifier: gene_id' label: 'Qualifier: gene_id' name: 'Qualifier: Score' label: 'Qualifier: Score' name: 'Qualifier: Pam' label: 'Qualifier: Pam' name: 'Qualifier: Doench' label: 'Qualifier: Doench' name: 'Qualifier: oof' label: 'Qualifier: oof' name: 'Qualifier: fusiPerc' label: 'Qualifier: fusiPerc' name: 'Qualifier: fusiAbs' label: 'Qualifier: fusiAbs' name: 'Qualifier: crisprScanPerc' label: 'Qualifier: crisprScanPerc' name: 'Qualifier: CrisprScanAbs' label: 'Qualifier: CrisprScanAbs'
name: 'annotation.[0|1|2|...].condition' label: '' default value: 'is' current value: 'is' possible values: name: 'is' label: 'Is' name: 'is_not' label: 'Is not' name: 'contains' label: 'Contains' name: 'does_not_contain' label: 'Does not contain'
===========
name: 'annotation.0.field' label: '' default value: 'Annotation type' current value: 'Annotation name'
possible values:
name: 'Annotation type' label: 'Annotation type'
name: 'Annotation name' label: 'Annotation name'
name: 'Any annotation qualifier' label: 'Any annotation qualifier'
name: 'Every annotation qualifier' label: 'Every annotation qualifier'
name: 'Annotation track name' label: 'Annotation track name'
name: 'Qualifier: note' label: 'Qualifier: note'
name: 'Qualifier: organism' label: 'Qualifier: organism'
name: 'Qualifier: mol_type' label: 'Qualifier: mol_type'
name: 'Qualifier: db_xref' label: 'Qualifier: db_xref'
name: 'Qualifier: chromosome' label: 'Qualifier: chromosome'
name: 'Qualifier: NCBI Feature Key' label: 'Qualifier: NCBI Feature Key'
name: 'Qualifier: gene' label: 'Qualifier: gene'
name: 'Qualifier: product' label: 'Qualifier: product'
name: 'Qualifier: inference' label: 'Qualifier: inference'
name: 'Qualifier: anticodon' label: 'Qualifier: anticodon'
name: 'Qualifier: NCBI Join Type' label: 'Qualifier: NCBI Join Type'
name: 'Qualifier: gene_synonym' label: 'Qualifier: gene_synonym'
name: 'Qualifier: standard_name' label: 'Qualifier: standard_name'
name: 'Qualifier: pseudo' label: 'Qualifier: pseudo'
name: 'Qualifier: estimated_length' label: 'Qualifier: estimated_length'
name: 'Qualifier: gap_type' label: 'Qualifier: gap_type'
name: 'Qualifier: transcript_id' label: 'Qualifier: transcript_id'
name: 'Qualifier: number' label: 'Qualifier: number'
name: 'Qualifier: exception' label: 'Qualifier: exception'
name: 'Qualifier: ncRNA_class' label: 'Qualifier: ncRNA_class'
name: 'Qualifier: codon_start' label: 'Qualifier: codon_start'
name: 'Qualifier: protein_id' label: 'Qualifier: protein_id'
name: 'Qualifier: translation' label: 'Qualifier: translation'
name: 'Qualifier: transl_except' label: 'Qualifier: transl_except'
name: 'Qualifier: EC_number' label: 'Qualifier: EC_number'
name: 'Qualifier: Source' label: 'Qualifier: Source'
name: 'Qualifier: gene_id' label: 'Qualifier: gene_id'
name: 'Qualifier: Score' label: 'Qualifier: Score'
name: 'Qualifier: Pam' label: 'Qualifier: Pam'
name: 'Qualifier: Doench' label: 'Qualifier: Doench'
name: 'Qualifier: oof' label: 'Qualifier: oof'
name: 'Qualifier: fusiPerc' label: 'Qualifier: fusiPerc'
name: 'Qualifier: fusiAbs' label: 'Qualifier: fusiAbs'
name: 'Qualifier: crisprScanPerc' label: 'Qualifier: crisprScanPerc'
name: 'Qualifier: CrisprScanAbs' label: 'Qualifier: CrisprScanAbs'
name: 'annotation.0.condition' label: '' default value: 'is' current value: 'contains'
possible values:
name 'is' label: 'Is'
name 'is_not' label: 'Is not'
name 'contains' label: 'Contains'
name 'does_not_contain' label: 'Does not contain'
name: 'annotation.0.value' label: '' default value: '' current value: ''
===========
name: 'whatToExtract' label: 'What to extract:' description: 'What to extract based on the criteria above' default value: 'annotatedRegion' current value: 'annotatedRegion'
possible values:
name: 'annotatedRegion' label: 'Annotated Region'
name: 'regionInverse' label: 'Inverse of annotated region' description: 'Extract all regions that don't match criteria'
name: 'entireSequence' label: 'Entire Sequence' description: 'Extract all sequences with an annotation matching criteria'
name: 'entireInverse' label: 'Non-matching sequences' description: 'Extract all sequences with no annotations matching criteria'
name: 'intersecting' label: 'Intersecting Annotations:' description: 'What to do with other annotations that intersect with the matched region' default value: 'includeContained' current value: 'includeContained'
possible values:
name: 'exclude' label: 'Exclude'
name: 'include' label: 'Include All'
name: 'includeContained' label: 'Include fully contained'
name: 'concatenate' label: 'Concatenate regions within each sequence' description: 'If this is on and there are multiple matching regions within a sequence, the regions will be concatenated' default value: 'false' current value: 'false'
possible values: 'true' or 'false'
name: 'includeIntergenicRegionsOption' label: 'Include Intergenic Regions' description: 'Include regions between intervals in annotations with multiple intervals' default value: 'false' current value: 'false'
possible values: 'true' or 'false'
name: 'dontMatchTruncated' label: 'Don't match truncated annotations' description: 'For the specified type of annotation, don't match if the annotation is marked as truncated on either end' default value: 'false' current value: 'false'
possible values: 'true' or 'false'
name: 'extractionContextOptions.includeUpstreamBasesOption' label: 'Include upstream (5') flanking bases: ' default value: 'false' current value: 'true'
possible values: 'true' or 'false'
name: 'extractionContextOptions.numUpstreamBasesOption' label: '' default value: '0' current value: '10000'
possible values: any integer between '0' and '2147483647'
name: 'extractionContextOptions.includeDownstreamBasesOption' label: 'Include downstream (3') flanking bases: ' default value: 'false' current value: 'true'
possible values: 'true' or 'false'
name: 'extractionContextOptions.numDownstreamBasesOption' label: '' default value: '0' current value: '10000'
possible values: any integer between '0' and '2147483647'
\ No newline at end of file
package de.mpicbg.gef.extractannotationlist;
import com.biomatters.geneious.publicapi.components.Dialogs;
import com.biomatters.geneious.publicapi.documents.AnnotatedPluginDocument;
import com.biomatters.geneious.publicapi.documents.sequence.SequenceDocument;
import com.biomatters.geneious.publicapi.plugin.*;
import com.biomatters.geneious.publicapi.utilities.StringUtilities;
import jebl.util.CompositeProgressListener;
import jebl.util.ProgressListener;
import java.util.*;
......@@ -74,67 +77,78 @@ public class GefExtractAnnotationListPlugin extends GeneiousPlugin {
@Override
public List<AnnotatedPluginDocument> performOperation(AnnotatedPluginDocument[] annotatedDocuments, ProgressListener progressListener, Options options) throws DocumentOperationException {
progressListener.setProgress(0d);
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();
// 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);
List<String> namesFound = new LinkedList<>();
for (AnnotatedPluginDocument doc : annotatedDocuments) {
DocumentOperation extractionOperation = PluginUtilities.getDocumentOperation("com.biomatters.plugins.extractAnnotations.ExtractAnnotationsOperation");
CompositeProgressListener compositeProgressListener = new CompositeProgressListener(progressListener, annotatedDocuments.length);
// Dialogs.showMessageDialog(StringUtilities.escapeHtmlCharacters(extractionOptions.getDescriptionAndState()));
//iterate over single documents because of performance reasons
for (AnnotatedPluginDocument doc:annotatedDocuments) {
compositeProgressListener.beginSubtask();
progressListener.setTitle(doc.getName());
Options extractionOptions = extractionOperation.getOptions(doc);
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");
//type
assert extractionOptions.setStringValue("annotation.1.field", "Annotation type");
assert extractionOptions.setStringValue("annotation.1.condition", "is");
assert extractionOptions.setStringValue("annotation.1.value", optionType);
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");
progressListener.setMessage(name);
compositeProgressListener.setProgress(namesWanted.indexOf(name), namesWanted.size());
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"
*/
List<AnnotatedPluginDocument> resultPerOperation = null;
try {
resultPerOperation = extractionOperation.performOperation(new AnnotatedPluginDocument[]{doc}, ProgressListener.EMPTY, extractionOptions);
} catch (Exception e) {
// Dialogs.showMessageDialog(e.toString());
}
if (resultPerOperation != null && !resultPerOperation.isEmpty()) {
results.addAll(resultPerOperation);
namesFound.add(name);
}
}//name
}//doc
for (String name : namesFound) {
namesWanted.remove(name);
}
if (!namesWanted.isEmpty())
Dialogs.showMessageDialog(namesWanted.toString(), "Not found");
return results;
......@@ -144,19 +158,21 @@ public class GefExtractAnnotationListPlugin extends GeneiousPlugin {
@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);
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