import java.util.*; import java.io.*; import org.biojava.bio.symbol.*; import org.biojava.bio.seq.*; import org.biojava.bio.seq.io.*; /** * Class that manages the program * @author Gard Thomassen * @see ProgramManager * @see PromoterSearcher * @see PromoterScoreManager * @see ScoreTable * @see PromoterSequenceScorer */ public class PromoterSearchManager { Vector score; PrintWriter out; Vector promoCand; Threshold threshold; PromoterSearcher promoSearcher; /** * Constructor ,establishes the actual threshold values * and the vector with the scoring info, and the vector for new candidates. * The construcot also creates a Printwriter for where * to print the Promoter Candidates * @param c is the vector with to store the candidates in * @param s is the vector containing info to score the sequences * @param thresholds an array with the user defined threhold percentages */ protected PromoterSearchManager(Vector c, Vector s, double [] thresholds ){ promoCand = c; score = s; //get the Thresholds established threshold = new Threshold(score); threshold.setThreshold(thresholds); //creating output stream try{ out = new PrintWriter(new BufferedWriter(new FileWriter("PromoterCandidates.txt"))); } catch(IOException e){ System.err.println("Trouble with creating output file"); } } /** *Method that runs the promoter search *Creates a PromoterSearcher object *Tells the PromoterSearcher to search for promoters *Then writes promoter candidates to the candidate vector *@param s is the sequence that is to be searched */ public void startSearch(Sequence s)throws Exception{ Sequence seq = s; promoSearcher = new PromoterSearcher(score); promoSearcher.searchPromoter(seq); promoCand.addAll(promoSearcher.cleanAndStore()); } /** * This method writes all promoter data to file * */ public void writePromoterCandidatesToFile(){ //iterator help int i = 0; // a candidate pointer used in the iteration PromoterCandidate cand; //iterate through all candidates while(i < promoCand.size()){ cand = (PromoterCandidate)promoCand.elementAt(i); //writing data to file cand.writeCandidateToFile(out, i); i++; }//end while System.out.println(""); System.out.println("Located : " +promoCand.size()+ " promoter candidates" ); out.close(); }//end write method //method for debugging (not used in the actual program) public void testName(){ Vector names = new Vector(); PromoterCandidate cand; int z = 0; System.out.print(promoCand.size()+"\n"); while(z < promoCand.size()){ cand = (PromoterCandidate)promoCand.elementAt(z); if(!names.contains(cand.seq_name)){ names.addElement(cand.seq_name); } z++; } System.out.println("Number of different sigma factor names"+names.size()); } }//end Manager