001 package calhoun.analysis.crf.test;
002
003 import java.util.List;
004
005 import calhoun.analysis.crf.AbstractFeatureManager;
006 import calhoun.analysis.crf.FeatureList;
007 import calhoun.analysis.crf.FeatureManagerEdge;
008 import calhoun.analysis.crf.ModelManager;
009 import calhoun.analysis.crf.io.InputSequence;
010 import calhoun.analysis.crf.io.TrainingSequence;
011
012 /** Implements basic constraints on gene calls.
013 *
014 * 1) Intergenic - start must occur at ATG
015 * 2) Splice sites must be canonical GT/AG or GC/AG
016 * 3) Exon-stop must be followed by a start codon
017 */
018
019 // NOTE: I don't think these constraints look at frame, so I recommend using a version of this class adapted to the specific model yu're considering. JPV 20060629
020
021 public class GeneConstraintsToy extends AbstractFeatureManager<Character> implements FeatureManagerEdge<Character> {
022
023 private static final long serialVersionUID = -3753476830756229273L;
024
025 public String getFeatureName(int featureIndex) {
026 return "Gene constraints toy";
027 }
028
029 /** This is a constraint class, so we don't return features */
030 public int getNumFeatures() {
031 return 0;
032 }
033
034 /** Set up the matrix
035 * Depends on states starting with the words 'intergenic, intron, and exon'. Also depends on the negative strand states ending in m.
036 */
037 public void train(int startingIndex, ModelManager modelInfo, List<? extends TrainingSequence<? extends Character>> data) {
038
039 }
040
041 public void evaluateEdge(InputSequence<? extends Character> seq, int pos, int prevState, int state, FeatureList result) {
042 if (pos==500) {
043 if ( (state != 1) || (prevState!=0) ) {
044 //System.out.println("Just triggered the constraint in GeneConstraintsToy");
045 result.invalidate();
046 }
047 }
048 }
049
050 }