//--------------------------------------------------------------- HAlignandum makeProfile( const HAlignandum & seqa, const HAlignment & map_seqa2profile, const HAlignandum & seqb, const HAlignment & map_seqb2profile ) { debug_func_cerr(5); HProfile profile = toProfile(makeProfile( std::max( map_seqa2profile->getColTo(), map_seqb2profile->getColTo() ))); profile->add( seqa, map_seqa2profile ); profile->add( seqb, map_seqb2profile ); return profile; }
//--------------------------------------------------------------- HAlignandum makeProfile( const HMultAlignment & mali, const HAlignandumVector & sequences ) { debug_func_cerr(5); if (sequences->size() != mali->getNumSequences()) throw AlignlibException( "ImplProfile.cpp: number of sequences given does not match number of sequences in MultAlignment"); HProfile profile = toProfile(makeProfile( mali->getLength() )); for (int x = 0; x < mali->getNumSequences(); ++x) profile->add( (*sequences)[x], (*mali)[x], true ); return profile; }
std::string calculateConservation( const HMultipleAlignment & mali, const Frequency min_frequency ) { debug_func_cerr(5); const HEncoder encoder(getDefaultEncoder()); HProfile profile( toProfile( (makeProfile( mali )))); profile->prepare(); const HFrequencyMatrix frequencies(profile->getFrequencyMatrix()); Position length = frequencies->getNumRows(); Residue width = frequencies->getNumCols(); char * buffer = new char[length + 1]; for (Position col = 0; col < length; col++) { Frequency max_frequency = min_frequency; Frequency f; Residue max_residue = encoder->getGapCode(); const Frequency * fcolumn = frequencies->getRow(col); for (Position row = 0; row < width; row++) { if ( (f = fcolumn[row]) >= max_frequency ) { max_frequency = f; max_residue = row; } } buffer[col] = encoder->decode( max_residue ); } buffer[length] = '\0'; std::string seq(buffer); delete [] buffer; return seq; }
void fragFind(struct seqList *goodSeq, char *badName, int fragSize, int mismatchesAllowed, boolean considerRc, double profile[16][4]) /* Do fast finding of patterns that are in FA file "goodName", but not in FA file * "badName." BadName can be null. Pass in the size of the pattern (fragSize) and * the number of mismatches to pattern you're willing to tolerate (mismatchesAllowed). * It returns the pattern in profile. */ { int *goodTable, *badTable = NULL; int goodCount, badCount = 0; int goodIx; long startTime; DNA unpacked[17]; if (mismatchesAllowed > 3) errAbort("Sorry, fragFind can only handle 0-3 mismatches."); if (fragSize > 10) errAbort("Sorry, fragFind can only handle fragments up to 10 bases."); startTime = clock1000(); makeOligoHistogram(NULL, goodSeq, fragSize, &goodTable, &goodCount); if (badName) makeOligoHistogram(badName, NULL, fragSize, &badTable, &badCount); if (badName) { normalizeTable(goodTable, fragSize); normalizeTable(badTable, fragSize); diffTables(goodTable, badTable, fragSize); goodIx = fuzzVal(badTable, fragSize, mismatchesAllowed, considerRc); } else { goodIx = fuzzVal(goodTable, fragSize, mismatchesAllowed, considerRc); } freez(&goodTable); freez(&badTable); unpackVal(goodIx, fragSize, unpacked); makeProfile(unpacked, fragSize, mismatchesAllowed, goodSeq, considerRc, profile); }
/** create empty profile * */ HAlignandum makeProfile() { return makeProfile(); }