import java.util.*; import java.io.*; import org.biojava.bio.symbol.*; import org.biojava.bio.seq.*; import org.biojava.bio.seq.io.*; /** * Class that does the promoter search. * @author Gard Thomassen * @see PromoterSearchManager * @see PromoterSequenceScorer * @see PromoterCandidate */ public class PromoterSearcher{ PromoterSearcher m = this; Vector score; PromoterSequenceScorer promoSequenceScorer; int s,f; Sequence seq; Vector tmpCand = new Vector(10,10); /** * Constructor, recieves the needed scoring and candidate vectors, * creates a PromoterSequenceScorer object. * @param s A vector that holds the scoring tables */ public PromoterSearcher(Vector s){ score = s; promoSequenceScorer = new PromoterSequenceScorer(score); } /** * Method that searches through the parameter sequence for * possible promoter sites, according to the user-chosen * promoters to search for. * Candidates are put into the candidates Vector of the Manager. * @param se the sequence that is to be searched in */ public void searchPromoter(Sequence se){ seq = se; int i = 0; ScoreTable table = (ScoreTable)score.elementAt(i); boolean t = true; while(t){ s = 1 ; f = table.A_score.length; boolean more = true; while(more){ if(f <= seq.length()){ promoSequenceScorer.scoreSequence(seq.subStr(s,f),i,tmpCand, m); s++; f++; } else{ more = false; } } //takes care of iteration i = i+2; if(i < score.size()) table = (ScoreTable)score.elementAt(i); else t = false; } }//end searchPromoter /** * Method that is called from the PromoterSequenceScorer object * that this object has created * Method returns the given string where the promoSequenceScorer * wants to search for the -10 region * @param d the distance from the -35 to the -10 region * @param i the index of the right scoretable object in the score Vector * @return string the string that is wanted or EOF if OutOfBounds */ public String getSeqv(int d, int i){ int score_length; ScoreTable m = (ScoreTable)score.elementAt(i); score_length = m.A_score.length; int s2,f2; f2 = s-d-1; s2 = f2-score_length+1; String tmp; //used for debugging //System.err.println("s2 = " +s2 + " f = "+ f); //System.err.println("Seq_length= " +seq.length()); if(s2 >= 1){ promoSequenceScorer.setName(seq.getName()); promoSequenceScorer.setStart(s2); promoSequenceScorer.setFinish(f); return( seq.subStr(s2,f2)); } //handling errors else return "OOB"; }//end getSeqv /** * Method that looks at almost similar candidates. * Almost similar is if both the start and the stop of two sequences * are no more than +/- 10 positions apart. * The method computes the best candidate and deletes the rest. * The method is called from the PromtoerSearchManager * @return a vector with the remaining candidates after the cleaning. */ public Vector cleanAndStore(){ String name, pName; int start = 0, stop = 0 ; double candScore = 0; PromoterCandidate cand,tmp; int k; for(int i = 0; i < tmpCand.size(); i ++){ cand = (PromoterCandidate)tmpCand.elementAt(i); name = cand.seq_name; pName = cand.promoter_name; start = cand.start; stop = cand.finish; k = i+1; candScore = cand.score35 + cand.score10 ; if(k < tmpCand.size()){ tmp = (PromoterCandidate)tmpCand.elementAt(k); while(k < tmpCand.size() && tmp.seq_name.equals(name) && pName.equals(tmp.promoter_name)){ tmp = (PromoterCandidate)tmpCand.elementAt(k); if(((((start-tmp.start) <= 10) && (start-tmp.start) >= 0 ) || (((tmp.start - start) <= 10) && ((tmp.start - start) >= 0))) && ((((stop-tmp.finish) <= 10) && (stop-tmp.finish) >= 0) || (((tmp.finish - stop) <= 10) && ((tmp.finish - stop) >= 0))) &&(cand.promoter_name.equals(tmp.promoter_name))) { if((tmp.score35 + tmp.score10) <= candScore){ tmp = (PromoterCandidate)tmpCand.remove(k); k--; } else{ tmp = (PromoterCandidate)tmpCand.remove(i); k = tmpCand.size(); i--; } } k++; } } } return tmpCand; } }//end class