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 whole program * @author Gard Thomassen * @see Invoke * @see PromoterSearchManager * @see TerminatorSearchManager * @see CandidateComputer * @see ResultPrinter */ public class ProgramManager { boolean [] consensuses; Vector promoterCandidate = new Vector(10,10); Vector terminatorCandidate = new Vector(10,10); Vector ncRNACandidates = new Vector(10,10); PromoterSearchManager promoter; TerminatorSearchManager terminator; SeqTools tools = new SeqTools(); CandidateComputer candidateComp; Vector promoterScore = new Vector(10,10); Sequence sequence, reversedCompliment; String fileName; SequenceIterator seqReader; double thresholds [] ; /** * Constructor ProgramManager * Establishes connection between pointers and parameters * @param c an array with the consensuses that should be searched for * @param f the name of the inputfile * @param s a sequence iterator connected to the inputfile * @param t an array with the thresholds to the given consensuses */ protected ProgramManager(boolean [] c,String f, SequenceIterator s, double [] t){ consensuses = c; fileName = f; seqReader = s; thresholds = t; } /** * This method controls the entire program, first thing is to establish the scoretables for the * promoters * Next is to read one and one FASTA format sequnce at the time via the FASTA_Reader * Then it creates an object of the * PromoterSearchManager, and calls the function in this object that * searches promoters, and puts them in the promoterCandidates Vector. * then the same happens for the terminators. * Then the candidate vectors are sent to an object of the CandidateComputer class, * the final ncRNA candidates are stored in the vector ncRNACandidates * Last thing is to print the results via a ResultPrinter object. */ public void start_ncRNAfinder()throws Exception{ boolean more = true; PromoterScoreManager promoScoreManager = new PromoterScoreManager(promoterScore, consensuses); promoter = new PromoterSearchManager(promoterCandidate, promoterScore, thresholds); terminator = new TerminatorSearchManager(terminatorCandidate); candidateComp = new CandidateComputer(promoterCandidate, terminatorCandidate, ncRNACandidates); int z = 0; System.out.println("The program is processing your FASTA file, please wait .."); try{ while(seqReader.hasNext()){ sequence = seqReader.nextSequence(); System.out.print("."); //searching the sequence promoter.startSearch(sequence); terminator.startSearch(sequence); //compute the ncRNA candidates candidateComp.computeCandidates(); //revers complimenting the sequence reversedCompliment = sequence; reversedCompliment = tools.reverseCompliment(reversedCompliment); //searching the reverse compliment of the sequence promoter.startSearch(reversedCompliment); terminator.startSearch(reversedCompliment); //compute the ncRNA candidates candidateComp.computeCandidates(); }//end while(more) } catch(Exception e){ System.err.println("Error occured while reading FASTA input file"); } //print results System.out.println("Computing and printing candidates to file, pleas wait"); promoter.writePromoterCandidatesToFile(); terminator.printTermCandidatesToFile(); ResultPrinter printer = new ResultPrinter(ncRNACandidates, fileName); printer.printAllncRNACandidates(); }//end start_ncRNAfinder }//end class ProgramManager