import java.io.*; import java.util.*; import org.biojava.bio.symbol.*; import org.biojava.bio.seq.*; import org.biojava.bio.seq.io.*; /** * Class TerminatorSearchManager, searches for * terminators, stores candidates in a * terminatorCandidates Vector * @author Gard Thomassen * @see ProgramManager * @see TerminatorSearcher * @see TerminatorCandidate */ public class TerminatorSearchManager{ Vector termCand; TerminatorSearcher termSearcher; PrintWriter outTerm; /** * Constructor that creates a pointer to the vector * of terminator candidates. It also creates a Printwriter * for where to print the TerminatorCandiates * @param t the vector holding all TerminatorCandiates */ protected TerminatorSearchManager(Vector t){ termCand = t; //creating outputStream try{ outTerm = new PrintWriter(new BufferedWriter(new FileWriter("TerminatorCandidates.txt"))); } catch(IOException e){ System.err.println("Trouble while creating output stream for terminator candidates"); } } /** * This method initiates the overall search by creating a TerminatorSearcher * object and then it fills the TerminatorCandidate vector by calling the * TermiantorSearchers method startTermSearch. * @param s the sequence to search for terminators */ public void startSearch(Sequence s){ termSearcher = new TerminatorSearcher(); termCand.addAll(termSearcher.startTermSearch(s)); } /** * This method prints all Terminator candidate info to a file * specified by the FileWriter created in this class' constructor. */ public void printTermCandidatesToFile(){ TerminatorCandidate cand; int i = 0; //iterate through all Terminator Candidates while(i < termCand.size()){ cand = (TerminatorCandidate)termCand.elementAt(i); //writing data to file cand.writeTerminatorCandidatesToFile(outTerm, i); i++; }//end while System.out.println("Located : " + termCand.size() + " terminator candidates"); outTerm.close(); }//end PrintterminatorCandidatesToFile }//end class TerminatorSearcher