ret = residues.find(eaa);
43ret = residues.find(
'X');
45 return static_cast<unsigned char>(ret);
49 return kResidues[
static_cast<int>(stdCode)];
64: m_masterIn(
false), m_residueRowsMap(), m_residueTypeCount(0), m_indexByConsensus(-1)
124 unsigned int max= 0;
146 doublew = 1.0/denom;
157 doublew = 1.0/denom;
172rowWeights[cit->second.first] += colResWeight;
173total += colResWeight;
174rowsUsed.
insert(cit->second.first);
176 if(countGap && ((
int)rowsUsed.
size() < numRows))
178 doublegapWeight = (1.0 - total) / (numRows - rowsUsed.
size());
179 for(
int row= 0;
row< numRows;
row++)
181 if(rowsUsed.
find(
row) != rowsUsed.
end())
182rowWeights[
row] += gapWeight;
190 doubletotalWeight = 0;
191 doublemaxResWeight = 0;
192 doubleresWeight = 0;
195pair <ResidueRowsMap::const_iterator, ResidueRowsMap::const_iterator> range =
200 int row= cit->second.first;
201resWeight += rowWeights[
row];
203 if(resWeight > maxResWeight)
206maxResWeight = resWeight;
208totalWeight += resWeight;
222residues[rit->second.first] = rit->first;
241pair <ResidueRowsMap::const_iterator, ResidueRowsMap::const_iterator> range =
245 if(cit->second.first ==
row)
246 returncit->second.second;
255 return(*cit)->second.second;
265 if(!(cit->second.second))
291backgroundResFreq[
'A'] = 7.67/100.0;
292backgroundResFreq[
'R'] = 5.21/100.0;
293backgroundResFreq[
'N'] = 4.32/100.0;
294backgroundResFreq[
'D'] = 5.25/100.0;
295backgroundResFreq[
'C'] = 1.62/100.0;
296backgroundResFreq[
'Q'] = 3.93/100.0;
297backgroundResFreq[
'E'] = 6.48/100.0;
298backgroundResFreq[
'G'] = 6.88/100.0;
299backgroundResFreq[
'H'] = 2.25/100.0;
300backgroundResFreq[
'I'] = 5.85/100.0;
301backgroundResFreq[
'L'] = 9.56/100.0;
302backgroundResFreq[
'K'] = 5.95/100.0;
303backgroundResFreq[
'M'] = 2.37/100.0;
304backgroundResFreq[
'F'] = 4.08/100.0;
305backgroundResFreq[
'P'] = 4.89/100.0;
306backgroundResFreq[
'S'] = 7.04/100.0;
307backgroundResFreq[
'T'] = 5.55/100.0;
308backgroundResFreq[
'W'] = 1.20/100.0;
309backgroundResFreq[
'Y'] = 3.14/100.0;
310backgroundResFreq[
'V'] = 6.63/100.0;
316 static double* backgroundResFreqArray = 0;
318 if(backgroundResFreqArray == 0)
336 doublefreqThreshold = 0.0001f;
338 const doubleln2 =
log(2.0f);
347 if( standardFreq > freqThreshold)
349 doublefreq = double(
count)/total;
350 doublefreqRatio = freq/standardFreq;
351 if(freqRatio > freqThreshold)
352 info+= freq * (
log(freqRatio))/ln2;
362: mPos(posOnMaster), gap(aGap)
387: m_frequencyThreshold(0.5),
389m_profiles(), m_rowWeights(),
390m_consensus(), m_guideAlignment()
402 constvector<Block>& mBlocks =
bmp.getMaster().getBlocks();
403 constvector<Block>& sBlocks =
bmp.getSlave().getBlocks();
408 for(
unsigned intbn = 0; bn < mBlocks.size(); bn++)
410 for(
int i= 0;
i< mBlocks[bn].getLen();
i++)
412 intmPos = mBlocks[bn].getStart() +
i;
413 intsPos = sBlocks[bn].getStart() +
i;
415 m_profiles[col].addOccurence(mSeq[mPos], masterRow,
true);
419 if(bn != (mBlocks.size() -1))
421 intmPos = mBlocks[bn].getEnd();
422 intsPos = sBlocks[bn].getEnd();
424 intsGapLen =
bmp.getSlave().getGapToCTerminal(bn);
425 intmGapLen =
bmp.getMaster().getGapToCTerminal(bn);
429 for(
intgap =1; gap <= mGapLen; gap++)
432 m_profiles[col].addOccurence(mSeq[mPos+gap], masterRow,
false);
437 intmidOnMaster = mGapLen/2 + mGapLen%2;
438 intmid = sGapLen/2 + sGapLen%2;
439 for(
intgap =1; gap <= sGapLen; gap++)
444 if(gap <= midOnMaster)
447col.
mPos= mPos + gap;
451col.
mPos= mPos + midOnMaster;
452col.
gap= gap - midOnMaster;
457 intmPosNext = mBlocks[bn+1].getStart();
458 intsPosNext = sBlocks[bn+1].getStart();
459 int delta= sPosNext - (sPos + gap);
460 if(
delta<= (mGapLen/2))
467col.
mPos= mPosNext - (mGapLen/2);
481 boolcountGap =
false;
484 doubleweightsSum = 0;
489 inthighestCount = 0;
492 intaCount = cit->second.getSumCount();
493 if(aCount > highestCount)
494highestCount = aCount;
521 doubledefaultWeight = 0.0;
523defaultWeight = 1.0f * double(colUsed)/double(
m_totalRows);
526 intnoWeightRows = 0;
572blocksOnMaster.clear();
573blocksOnConsensus.clear();
577 boolinBlock =
false;
578 intstartM = 0, endM = 0;
591 boolqualifiedForConsensus = (
weight>= threshold && res );
592 boolqualifiedForGuide = qualifiedForConsensus && ((cit->second).isAligned(0));
597 if(qualifiedForGuide)
608 if(qualifiedForGuide)
611 if(col.
mPos== (endM + 1))
618blocksOnMaster.push_back(
Block(startM, endM - startM + 1, blockId));
619blocksOnConsensus.push_back(
Block(startC, endM - startM + 1, blockId));
630blocksOnMaster.push_back(
Block(startM, endM - startM + 1, blockId));
631blocksOnConsensus.push_back(
Block(startC, endM - startM + 1, blockId));
635 if(qualifiedForConsensus)
637cit->second.setIndexByConsensus(
m_consensus.size());
648blocksOnMaster.push_back(
Block(startM, endM - startM + 1, blockId));
649blocksOnConsensus.push_back(
Block(startC, endM - startM + 1, blockId));
699seq.assign(mcc.
getSeq());
708cr.
read(pit->second);
717 if(pit->first.gap == 0)
719 intmPos = pit->first.mPos;
721cr.
read(pit->second);
731 if(pit->second.getIndexByConsensus() >= 0)
732cr.
read(pit->second);
741 if(pit->second.isAllRowsAligned())
742cr.
read(pit->second);
756 booluseCol =
false;
761useCol = (cit->first.gap == 0);
792blocksOnMaster.clear();
793blocksOnConsensus.clear();
800 boolinBlock =
false;
801 intstartM = 0, endM = 0;
816 boolqualifiedForGuide = qualifiedForConsensus && ((cit->second).isAligned(0));
819 if(qualifiedForGuide)
830 if(qualifiedForGuide)
833 if(col.
mPos== (endM + 1))
840blocksOnMaster.push_back(
Block(startM, endM - startM + 1, blockId));
841blocksOnConsensus.push_back(
Block(startC, endM - startM + 1, blockId));
852blocksOnMaster.push_back(
Block(startM, endM - startM + 1, blockId));
853blocksOnConsensus.push_back(
Block(startC, endM - startM + 1, blockId));
858 if(qualifiedForConsensus)
861 if(curMap.
find(conIndex) != curMap.
end()) {
870 if(curMap.
find(conIndex) != curMap.
end()) {
881blocksOnMaster.push_back(
Block(startM, endM - startM + 1, blockId));
882blocksOnConsensus.push_back(
Block(startC, endM - startM + 1, blockId));
889vector<UnalignedSegReader::Seg> segs;
891 if(segs.size() == 0)
906 for(
unsigned int i= 0;
i< segs.size();
i++)
908 for(
intk = segs[
i].
first; k <= segs[
i].second; k++)
914: m_totalUnaligned(0), m_pos(0)
976 returnseg.second - seg.first + 1 ;
981 string head=
in.substr(0, seg.first);
982 stringtail =
in.substr(seg.second + 1,
in.size() - (seg.second + 1));
Various auxiliary BLAST utility functions.
double * BLAST_GetStandardAaProbabilities(void)
Get the standard amino acid probabilities.
vector< Block > & getBlocks()
bool operator<(const ColumnAddress &rhs) const
virtual void read(ColumnResidueProfile &crp)=0
double calculateColumnWeight(char residue, bool countGap, int numRows) const
double reweightColumnByRowWeights(const vector< double > &rowWeights, char &heaviestResidue) const
void addOccurence(char residue, int row, bool aligned)
unsigned char getResidueByRow(int row)
static int getResiduesStringSize()
pair< int, bool > RowStatusPair
static const string getResiduesString()
ResidueRowsMap::iterator * findRow(int row)
int getIndexByConsensus() const
bool isAllRowsAligned() const
double getBackgroundResFreq(char res)
void setIndexByConsensus(int col)
vector< ResidueRowsMap::iterator * > m_residuesByRow
double sumUpColumnWeightsByRow(vector< double > &rowWeights, bool countGap, int numRows) const
void getResiduesByRow(vector< char > &residues, bool byNcbiStd=true) const
ResidueRowsMap m_residueRowsMap
double calcInformationContent()
char getMostFrequentResidue(int &count) const
static unsigned char getNcbiStdCode(char eaa)
static char getEaaCode(char stdCode)
static void useDefaultBackgroundResFreq()
int getResidueTypeCount() const
bool isAligned(char residue, int row) const
vector< double > m_rowWeights
const string & makeConsensus()
set< int > m_colsToSkipOnConsensus
UnqualForConsMap::const_iterator UnqualForConsCit
void adjustConsensusAndGuide()
void traverseColumnsOnMaster(ColumnReader &cr)
BlockModelPair m_guideAlignment
UnqualForConsMap m_numUnqualAfterConsIndex
double calcInformationContent(bool byConsensus=true)
const string getConsensus(bool inNcbieaa=true)
set< int > m_colsToSkipOnMaster
void traverseAlignedColumns(ColumnReader &cr)
void countUnalignedConsensus(UnalignedSegReader &ucr)
const BlockModelPair & getGuideAlignment() const
bool HasUnqualAfterIndex(int index) const
int countColumnsOnMaster(string &seq)
unsigned int GetNumUnqualAfterIndex(int index) const
void calculateRowWeights()
void addOneRow(BlockModelPair &bmp, const string &mSeq, const string &sSeq)
void traverseAllColumns(ColumnReader &cr)
void traverseColumnsOnConsensus(ColumnReader &cr)
vector< CRef< CSeq_id > > m_seqIds
bool skipUnalignedSeg(UnalignedSegReader &ucr, int len)
void segsToSet(vector< UnalignedSegReader::Seg > &segs, set< int > &cols)
double m_frequencyThreshold
void read(ColumnResidueProfile &crp)
string getIndexSequence()
int getLongUnalignedSegs(int length, vector< Seg > &segs)
string subtractSeg(Seg seg, string &in)
vector< Seg > m_unalignedSegs
string subtractLongestSeg(int threshold)
void setIndexSequence(string &seq)
container_type::const_iterator const_iterator
container_type::iterator iterator
const_iterator begin() const
const_iterator end() const
const_iterator find(const key_type &key) const
const_iterator_pair equal_range(const key_type &key) const
container_type::const_iterator const_iterator
const_iterator end() const
iterator insert(const value_type &val)
const_iterator begin() const
container_type::iterator iterator
container_type::value_type value_type
iterator_bool insert(const value_type &val)
const_iterator find(const key_type &key) const
const_iterator end() const
static CSafeStatic< map< char, double > > s_BackgroundResFreq
static const size_t kResiduesSize
static const char kResidues[]
thread_local unique_ptr< FtaMsgPost > bmp
static DLIST_TYPE *DLIST_NAME() first(DLIST_LIST_TYPE *list)
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define END_SCOPE(ns)
End the previously defined scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
#define BEGIN_SCOPE(ns)
Define a new scope.
unsigned int
A callback function used to compare two keys in a database.
std::istream & in(std::istream &in_, double &x_)
Int4 delta(size_t dimension_, const Int4 *score_)
#define row(bind, expected)
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4