void FeatureInvestigator::printBayesian ( Persistance::TextWriter& writer, Feature& feature, const PositionVector& positions) { const int motifLength = feature.assignment ().length (); CPositionIterator it (positions.begin (), positions.end ()); for (; it.hasNext () ; it.next()) { const SeqPosition& position = *(*it); StrBuffer buf; USELESS (int middleSection = ) position.getSeedString (buf, motifLength, _outputLength, '?'); writer << '('; int length = buf.length(); for (int i=0 ; i<length ; i++) { writer << buf [i] << ' '; } writer << ')'; writer.writeln (); } }
void FeatureInvestigator::printSeed (Persistance::TextTableReport::Output& out, Feature& feature, const PositionVector& positions) { int currentField = Persistance::TextTableReport::firstFieldIndex; Persistance::TextTableReport::Data data (_seedFormat); TextWriter writer (NULL); // // print all scores Scores::Score_ptr score = feature.score (); while (score) { writer.setStream (data.getOutputStream(currentField++)); writer << (- score->log10Score ()); score = score->next (); } // // print the assignment writer.setStream (data.getOutputStream(currentField++)); writer << _parameters.langauge ().format (feature.assignment ()); // // print score params if available writer.setStream (data.getOutputStream(currentField++)); feature.score ()->writeAsText (writer); /* if (feature.scoreParameters ()) { writer << '['; feature.scoreFunction ().writeAsText (writer, feature.scoreParameters ()); writer << ']'; }*/ // // print projection details if available writer.setStream (data.getOutputStream(currentField++)); if (feature.projection ()) { writer << _parameters.langauge ().format (*feature.projection ()); } /* // // print how many seeds counted for bonf correction, if available writer.setStream (data.getOutputStream(currentField++)); if (feature.numSeedsSearched () > 0) { writer << feature.numSeedsSearched(); } */ writer.setStream (NULL); out << data; }
void FeatureInvestigator::createPSSM (PositionWeightType positionWeightType, Feature& feature_i, const PositionVector& positions, PSSM& outPSSM) { const int seed_length = feature_i.assignment ().length (); outPSSM = PSSM ( positionWeightType, _parameters.langauge ().code (), seed_length, _outputLength, positions, *_parameters.wf ()); }
// // adds the positive positions of the feature to the position vector void FeatureInvestigator::addPositions ( Feature& feature, PositionVector& outPositives, PositionVector& outNegatives) { // // use the positions in the cluster if they are available if (!feature.cluster ().hasPositions ()) { // // it is assumed that if it has any positions, then // it contains all relevant positions Preprocessor::NodeCluster motifNodes; _parameters.preprocessor ().add2Cluster ( motifNodes, feature.assignment ()); motifNodes.add2SeqClusterPositions (feature.cluster ()); } SeqCluster::AddPositions pos(outPositives); SeqCluster::AddPositions neg(outNegatives); feature.cluster ().performDivided(*_parameters.wf (), pos, neg); }
void FeatureInvestigator::printMotifPosition ( Persistance::TextTableReport::Output& out, Feature& feature, const SeqPosition& position) { Persistance::TextTableReport::Data data (_motifPositionFormat); const int motifLength = feature.assignment ().length (); StrBuffer buf(_outputLength); int middleSection = position.getSeedString ( buf, motifLength, _outputLength ); int fieldIndex = Persistance::TextTableReport::firstFieldIndex; Persistance::TextWriter writer (data.getOutputStream (fieldIndex++)); writer << buf.substring (0, middleSection) << ' ' << buf.substring (middleSection, middleSection + motifLength) << ' ' << buf.substring (middleSection + motifLength); // // write seq id writer.setStream(data.getOutputStream(fieldIndex++)); writer << position.sequence ()->id (); // // write seq name writer.setStream(data.getOutputStream(fieldIndex++)); writer << position.sequence ()->name (); // // output sequence weight writer.setStream(data.getOutputStream(fieldIndex++)); writer << '[' << _parameters.wf ()->weight (position.sequence ()->id ()) << ']'; // // output the position information: // we write the position from the TSS, that is: // the upstream offset from the gene // the promoter is assumed to be on the same strand as the gene // and read in the same direction as the gene. // this means that the 'reverse' strand is the strand that DOES not // have the gene. // // // 98765|432|10 // TTTTT|TGC|TT <-- // --> AAAAA|ACG|AA // 01234|567|89 // // CGT-positions: 2-->5 // CGT-tssPositions (): 5-->8 = (10 - 2 - 3) --> (10 - 2) writer.setStream(data.getOutputStream(fieldIndex++)); int tssPosition = position.tssPosition (motifLength); writer << tssPosition; writer.setStream(data.getOutputStream(fieldIndex++)); writer << tssPosition + (position.strand ()? motifLength : - motifLength); // // print +/- if it is on normal/reverse strand writer.setStream(data.getOutputStream(fieldIndex++)); writer << (position.strand ()? '+' : '-'); // // print the sequence length writer.setStream(data.getOutputStream(fieldIndex++)); writer << position.sequence ()->length (); writer.setStream(NULL); out << data; }