package org.seqcode.gsebricks.verbs.location;
import java.util.Map;
import org.seqcode.genome.location.Point;
import org.seqcode.genome.location.StrandedRegion;
import org.seqcode.gsebricks.types.*;
import org.seqcode.gsebricks.verbs.Mapper;
/**
* Maps a StrandedRegion to its start site
*/
public class StrandedToStart<X extends StrandedRegion> implements Mapper<X,Point>, SelfDescribingVerb {
public StrandedToStart() {}
public Point execute(X a) {
switch(a.getStrand()) {
case '+':
return new Point(a.getGenome(),
a.getChrom(),
a.getStart());
case '-':
return new Point(a.getGenome(),
a.getChrom(),
a.getEnd());
default:
throw new IllegalArgumentException("Don't understand strand " + a.getStrand());
}
}
private static final String[] inputNames = { "StrandedRegions" };
private static final EchoType[] inputTypes = { new ClassType(StrandedRegion.class) };
private static final EchoType outputType = new ClassType(Point.class);
public EchoType[] getInputClasses() {
return inputTypes;
}
public String[] getInputNames() {
return inputNames;
}
public EchoType getOutputClass() {
return outputType;
}
public EchoType[] getParameterClasses() {
return null;
}
public String[] getParameterNames() {
return null;
}
public void init(Map<String, Object> params) {
}
}