@Override public void runDiscovery(MotifFactory factory) { System.err.println("run ab discovery"); ArrayList<Sequence> revSequences = BaseSequence.generateReverseComplements(sequences); // add sentinels and replace non ACGT chars with sentinel // not necessary to repeat this for every position + no deep copy of seqs! // long start = System.nanoTime(); ArrayList<Sequence> sequencesPreprocessed = GeneralizedSuffixTree.preprocessSequences(sequences, false); ArrayList<Sequence> revSequencesPreprocessed = GeneralizedSuffixTree.preprocessSequences(revSequences, false); // System.err.println("Seq preprocessing: "+(System.nanoTime()-start)/1000000); // start = System.nanoTime(); ArrayList<IndexStructure> forwardIndexes = generateIndexes(sequencesPreprocessed); ArrayList<IndexStructure> reverseIndexes = generateIndexes(revSequencesPreprocessed); // System.err.println("Index building: "+(System.nanoTime()-start)/1000000); if (extractor != null) { SortedSet<String> prefixes = generateAllPrefixes(); // int counter=0; // start = System.nanoTime(); prefixLoop: for (String prefix : prefixes) { // counter++; extractor.reset(); // flushes motif map before new prefix is procesed // System.out.println("p: "+prefix); if (countNumberOfDegs(prefix) > motifSearchSpace.getMaxNumberOfDegeneratePositions()) { continue prefixLoop; } for (int i = 0; i < sequences.get(0).length(); i++) { launchDiscoveryForPosition( i, factory, prefix, sequencesPreprocessed, forwardIndexes.get(i)); } for (int i = 0; i < revSequences.get(0).length(); i++) { launchDiscoveryForPosition( i, factory, prefix, revSequencesPreprocessed, reverseIndexes.get(i)); } /*if (counter%100==0){ System.err.println("Prefix: " + counter + " "+(System.nanoTime()-start)/1000000); start = System.nanoTime(); }*/ } } }