Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

...

Your plugin class name is inserted in the file as shown in the following code, as "MyPlugin".

Code Block
borderStylesolid
titlecom.myorg.myplugin.Activator.javaborderStylesolid
@Override
protected ServiceRegistration<?>[] registerService(IGBService igbService) throws Exception {
	return new ServiceRegistration[] {
		bundleContext.registerService(Operator.class, new MyPlugin(FileTypeCategory.Alignment), null),
		bundleContext.registerService(Operator.class, new MyPlugin(FileTypeCategory.Annotation), null),
		bundleContext.registerService(Operator.class, new MyPlugin(FileTypeCategory.ProbeSet), null)
	};
}

...

This sample code inherits AbstractAnnotationOperator and implements Operator interface to work as a new annotation operation. For more options refer to the Extension Points section.

Code Block
borderStylesolid
titlecom.myorg.myplugin.MyPlugin.javaborderStylesolid
public class MyPlugin extends AbstractAnnotationOperator implements Operator {

	// Constructor
	MyPlugin(FileTypeCategory category){
		super(category);
	}

	// Method to determine the internal plugin name
	@Override
	public String getName() {
		return this.category.toString().toLowerCase() +"_my_plugin";
	}


	// Method to determine the display name for the operation
	@Override
	public String getDisplay() {
		return "My Operation";
	}


	// Private method to check if two symmetries are overlapped used by the operate()
	private boolean overlap(BioSeq aseq, SeqSymmetry s0, SeqSymmetry s1) {
		return s0.getSpan(aseq) != null && s1.getSpan(aseq) != null && s0.getSpan(aseq).getMax() > s1.getSpan(aseq).getMin() && s0.getSpan(aseq).getMin() < s1.getSpan(aseq).getMax();
	}


	// Core code for the operation which loops over input symmetries and return the overlapped ones
	@Override
	public SeqSymmetry operate(BioSeq aseq, List<SeqSymmetry> symList) {
		SimpleSymWithProps result = new SimpleSymWithProps();
		result.setProperties(new HashMap<String,Object>());
		TypeContainerAnnot t0 = (TypeContainerAnnot)symList.get(0);
		TypeContainerAnnot t1 = (TypeContainerAnnot)symList.get(1);
		result.setProperty("type", t0.getType() + " " + getName());

		for (int i = 0; i < t0.getChildCount(); i++) {
			SeqSymmetry s0 = t0.getChild(i);
			for (int j = 0; j < t1.getChildCount(); j++) {
				SeqSymmetry s1 = t1.getChild(j);
				if (overlap(aseq, s0, s1)) {
					result.addChild(s0);
					result.addSpan(s0.getSpan(aseq));
					break;
				}
			}
		}
		return result;
	}

...