本文整理汇总了C++中SeqVect::Length方法的典型用法代码示例。如果您正苦于以下问题:C++ SeqVect::Length方法的具体用法?C++ SeqVect::Length怎么用?C++ SeqVect::Length使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SeqVect
的用法示例。
在下文中一共展示了SeqVect::Length方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Copy
void SeqVect::Copy(const SeqVect &rhs)
{
clear();
unsigned uSeqCount = rhs.Length();
for (unsigned uSeqIndex = 0; uSeqIndex < uSeqCount; ++uSeqIndex)
{
Seq *ptrSeq = rhs.at(uSeqIndex);
Seq *ptrSeqCopy = new Seq;
ptrSeqCopy->Copy(*ptrSeq);
push_back(ptrSeqCopy);
}
}
示例2: DistUnaligned
void DistUnaligned(const SeqVect &v, DISTANCE DistMethod, DistFunc &DF)
{
const unsigned uSeqCount = v.Length();
switch (DistMethod)
{
case DISTANCE_Kmer6_6:
DistKmer6_6(v, DF);
break;
case DISTANCE_Kmer20_3:
DistKmer20_3(v, DF);
break;
case DISTANCE_Kmer20_4:
FastDistKmer(v, DF);
break;
case DISTANCE_Kbit20_3:
DistKbit20_3(v, DF);
break;
case DISTANCE_Kmer4_6:
DistKmer4_6(v, DF);
break;
case DISTANCE_PWKimura:
DistPWKimura(v, DF);
break;
case DISTANCE_PWScoreDist:
DistPWScoreDist(v, DF);
break;
default:
Quit("DistUnaligned, unsupported distance method %d", DistMethod);
}
// const char **SeqNames = (const char **) malloc(uSeqCount*sizeof(char *));
for (unsigned uSeqIndex = 0; uSeqIndex < uSeqCount; ++uSeqIndex)
{
const Seq &s = *(v[uSeqIndex]);
const char *ptrName = s.GetName();
unsigned uId = s.GetId();
DF.SetName(uSeqIndex, ptrName);
DF.SetId(uSeqIndex, uId);
}
}
示例3: MHackStart
void MHackStart(SeqVect &v)
{
if (ALPHA_Amino != g_Alpha)
return;
const unsigned uSeqCount = v.Length();
M = new bool[uSeqCount];
memset(M, 0, uSeqCount*sizeof(bool));
for (unsigned uSeqIndex = 0; uSeqIndex < uSeqCount; ++uSeqIndex)
{
Seq &s = v.GetSeq(uSeqIndex);
if (0 == s.Length())
continue;
unsigned uId = s.GetId();
if (s[0] == 'M' || s[0] == 'm')
{
M[uId] = true;
s[0] = 'X';
}
}
}
示例4: DistPWScoreDist
void DistPWScoreDist(const SeqVect &v, DistFunc &DF)
{
SEQWEIGHT SeqWeightSave = GetSeqWeightMethod();
SetSeqWeightMethod(SEQWEIGHT_Henikoff);
const unsigned uSeqCount = v.Length();
DF.SetCount(uSeqCount);
const unsigned uPairCount = (uSeqCount*(uSeqCount + 1))/2;
unsigned uCount = 0;
SetProgressDesc("PW ScoreDist");
for (unsigned uSeqIndex1 = 0; uSeqIndex1 < uSeqCount; ++uSeqIndex1)
{
const Seq &s1 = v.GetSeq(uSeqIndex1);
MSA msa1;
msa1.FromSeq(s1);
for (unsigned uSeqIndex2 = 0; uSeqIndex2 < uSeqIndex1; ++uSeqIndex2)
{
if (0 == uCount%20)
Progress(uCount, uPairCount);
++uCount;
const Seq &s2 = v.GetSeq(uSeqIndex2);
MSA msa2;
msa2.FromSeq(s2);
PWPath Path;
MSA msaOut;
AlignTwoMSAs(msa1, msa2, msaOut, Path, false, false);
float d = (float) GetScoreDist(msaOut, 0, 1);
DF.SetDist(uSeqIndex1, uSeqIndex2, d);
}
}
ProgressStepsDone();
SetSeqWeightMethod(SeqWeightSave);
}
示例5: DoMuscle
void DoMuscle()
{
SetOutputFileName(g_pstrOutFileName.get());
SetInputFileName(g_pstrInFileName.get());
SetMaxIters(g_uMaxIters.get());
SetSeqWeightMethod(g_SeqWeight1.get());
TextFile fileIn(g_pstrInFileName.get());
SeqVect v;
v.FromFASTAFile(fileIn);
const unsigned uSeqCount = v.Length();
if (0 == uSeqCount)
Quit("No sequences in input file");
ALPHA Alpha = ALPHA_Undefined;
switch (g_SeqType.get())
{
case SEQTYPE_Auto:
Alpha = v.GuessAlpha();
break;
case SEQTYPE_Protein:
Alpha = ALPHA_Amino;
break;
case SEQTYPE_DNA:
Alpha = ALPHA_DNA;
break;
case SEQTYPE_RNA:
Alpha = ALPHA_RNA;
break;
default:
Quit("Invalid seq type");
}
SetAlpha(Alpha);
v.FixAlpha();
//
// AED 21/12/06: Moved matrix loading code inside the PP param function so it gets called for all alignment types
//
SetPPScore();
unsigned uMaxL = 0;
unsigned uTotL = 0;
for (unsigned uSeqIndex = 0; uSeqIndex < uSeqCount; ++uSeqIndex)
{
unsigned L = v.GetSeq(uSeqIndex).Length();
uTotL += L;
if (L > uMaxL)
uMaxL = L;
}
SetIter(1);
g_bDiags.get() = g_bDiags1.get();
SetSeqStats(uSeqCount, uMaxL, uTotL/uSeqCount);
SetMuscleSeqVect(v);
MSA::SetIdCount(uSeqCount);
// Initialize sequence ids.
// From this point on, ids must somehow propogate from here.
for (unsigned uSeqIndex = 0; uSeqIndex < uSeqCount; ++uSeqIndex)
v.SetSeqId(uSeqIndex, uSeqIndex);
if (0 == uSeqCount)
Quit("Input file '%s' has no sequences", g_pstrInFileName.get());
if (1 == uSeqCount)
{
TextFile fileOut(g_pstrOutFileName.get(), true);
v.ToFile(fileOut);
return;
}
if (uSeqCount > 1)
MHackStart(v);
// First iteration
Tree GuideTree;
if (0 != g_pstrUseTreeFileName.get())
{
// Discourage users...
if (!g_bUseTreeNoWarn.get())
fprintf(stderr, g_strUseTreeWarning);
// Read tree from file
TextFile TreeFile(g_pstrUseTreeFileName.get());
GuideTree.FromFile(TreeFile);
// Make sure tree is rooted
if (!GuideTree.IsRooted())
Quit("User tree must be rooted");
if (GuideTree.GetLeafCount() != uSeqCount)
Quit("User tree does not match input sequences");
//.........这里部分代码省略.........
示例6: DoMuscle
void DoMuscle(CompositeVect*CVLocation)
{
SetOutputFileName(g_pstrOutFileName);
SetInputFileName(g_pstrInFileName);
SetMaxIters(g_uMaxIters);
SetSeqWeightMethod(g_SeqWeight1);
TextFile fileIn(g_pstrInFileName);
SeqVect v;
v.FromFASTAFile(fileIn);
const unsigned uSeqCount = v.Length();
if (0 == uSeqCount)
Quit("No sequences in input file");
ALPHA Alpha = ALPHA_Undefined;
switch (g_SeqType)
{
case SEQTYPE_Auto:
Alpha = v.GuessAlpha();
break;
case SEQTYPE_Protein:
Alpha = ALPHA_Amino;
break;
case SEQTYPE_DNA:
Alpha = ALPHA_DNA;
break;
case SEQTYPE_RNA:
Alpha = ALPHA_RNA;
break;
default:
Quit("Invalid seq type");
}
SetAlpha(Alpha);
v.FixAlpha();
PTR_SCOREMATRIX UserMatrix = 0;
if (0 != g_pstrMatrixFileName)
{
const char *FileName = g_pstrMatrixFileName;
const char *Path = getenv("MUSCLE_MXPATH");
if (Path != 0)
{
size_t n = strlen(Path) + 1 + strlen(FileName) + 1;
char *NewFileName = new char[n];
sprintf(NewFileName, "%s/%s", Path, FileName);
FileName = NewFileName;
}
TextFile File(FileName);
UserMatrix = ReadMx(File);
g_Alpha = ALPHA_Amino;
g_PPScore = PPSCORE_SP;
}
SetPPScore();
if (0 != UserMatrix)
g_ptrScoreMatrix = UserMatrix;
unsigned uMaxL = 0;
unsigned uTotL = 0;
for (unsigned uSeqIndex = 0; uSeqIndex < uSeqCount; ++uSeqIndex)
{
unsigned L = v.GetSeq(uSeqIndex).Length();
uTotL += L;
if (L > uMaxL)
uMaxL = L;
}
SetIter(1);
g_bDiags = g_bDiags1;
SetSeqStats(uSeqCount, uMaxL, uTotL/uSeqCount);
SetMuscleSeqVect(v);
MSA::SetIdCount(uSeqCount);
// Initialize sequence ids.
// From this point on, ids must somehow propogate from here.
for (unsigned uSeqIndex = 0; uSeqIndex < uSeqCount; ++uSeqIndex)
v.SetSeqId(uSeqIndex, uSeqIndex);
if (0 == uSeqCount)
Quit("Input file '%s' has no sequences", g_pstrInFileName);
if (1 == uSeqCount)
{
TextFile fileOut(g_pstrOutFileName, true);
v.ToFile(fileOut);
return;
}
if (uSeqCount > 1)
MHackStart(v);
// First iteration
//.........这里部分代码省略.........
示例7: DistKmer6_6
void DistKmer6_6(const SeqVect &v, DistFunc &DF)
{
const unsigned uSeqCount = v.Length();
DF.SetCount(uSeqCount);
if (0 == uSeqCount)
return;
// Initialize distance matrix to zero
for (unsigned uSeq1 = 0; uSeq1 < uSeqCount; ++uSeq1)
{
DF.SetDist(uSeq1, uSeq1, 0);
for (unsigned uSeq2 = 0; uSeq2 < uSeq1; ++uSeq2)
DF.SetDist(uSeq1, uSeq2, 0);
}
// Convert to letters
unsigned **Letters = new unsigned *[uSeqCount];
for (unsigned uSeqIndex = 0; uSeqIndex < uSeqCount; ++uSeqIndex)
{
Seq &s = *(v[uSeqIndex]);
const unsigned uSeqLength = s.Length();
unsigned *L = new unsigned[uSeqLength];
Letters[uSeqIndex] = L;
for (unsigned n = 0; n < uSeqLength; ++n)
{
char c = s[n];
L[n] = CharToLetterEx(c);
assert(L[n] < uResidueGroupCount);
}
}
unsigned **uCommonTupleCount = new unsigned *[uSeqCount];
for (unsigned n = 0; n < uSeqCount; ++n)
{
uCommonTupleCount[n] = new unsigned[uSeqCount];
memset(uCommonTupleCount[n], 0, uSeqCount*sizeof(unsigned));
}
const unsigned uPairCount = (uSeqCount*(uSeqCount + 1))/2;
unsigned uCount = 0;
for (unsigned uSeq1 = 0; uSeq1 < uSeqCount; ++uSeq1)
{
Seq &seq1 = *(v[uSeq1]);
const unsigned uSeqLength1 = seq1.Length();
if (uSeqLength1 < 5)
continue;
const unsigned uTupleCount = uSeqLength1 - 5;
const unsigned *L = Letters[uSeq1];
CountTuples(L, uTupleCount, Count1);
#if TRACE
{
Log("Seq1=%d\n", uSeq1);
Log("Groups:\n");
for (unsigned n = 0; n < uSeqLength1; ++n)
Log("%u", ResidueGroup[L[n]]);
Log("\n");
Log("Tuples:\n");
ListCount(Count1);
}
#endif
SetProgressDesc("K-mer dist pass 1");
for (unsigned uSeq2 = 0; uSeq2 <= uSeq1; ++uSeq2)
{
if (0 == uCount%500)
Progress(uCount, uPairCount);
++uCount;
Seq &seq2 = *(v[uSeq2]);
const unsigned uSeqLength2 = seq2.Length();
if (uSeqLength2 < 5)
{
if (uSeq1 == uSeq2)
DF.SetDist(uSeq1, uSeq2, 0);
else
DF.SetDist(uSeq1, uSeq2, 1);
continue;
}
// First pass through seq 2 to count tuples
const unsigned uTupleCount = uSeqLength2 - 5;
const unsigned *L = Letters[uSeq2];
CountTuples(L, uTupleCount, Count2);
#if TRACE
Log("Seq2=%d Counts=\n", uSeq2);
ListCount(Count2);
#endif
// Second pass to accumulate sum of shared tuples
// MAFFT defines this as the sum over unique tuples
// in seq2 of the minimum of the number of tuples found
// in the two sequences.
unsigned uSum = 0;
for (unsigned n = 0; n < uTupleCount; ++n)
{
const unsigned uTuple = GetTuple(L, n);
uSum += MIN(Count1[uTuple], Count2[uTuple]);
//.........这里部分代码省略.........
示例8: DistKmer20_3
// WARNING: Sequences MUST be stripped of gaps and upper case!
void DistKmer20_3(const SeqVect &v, DistFunc &DF)
{
const unsigned uSeqCount = v.Length();
DF.SetCount(uSeqCount);
if (0 == uSeqCount)
return;
for (unsigned uSeq1 = 0; uSeq1 < uSeqCount; ++uSeq1)
{
DF.SetDist(uSeq1, uSeq1, 0);
for (unsigned uSeq2 = 0; uSeq2 < uSeq1; ++uSeq2)
DF.SetDist(uSeq1, uSeq2, 0);
}
const unsigned uTripleArrayBytes = TRIPLE_COUNT*sizeof(TripleCount);
TripleCounts = (TripleCount *) malloc(uTripleArrayBytes);
if (0 == TripleCounts)
Quit("Not enough memory (TripleCounts)");
memset(TripleCounts, 0, uTripleArrayBytes);
for (unsigned uWord = 0; uWord < TRIPLE_COUNT; ++uWord)
{
TripleCount &tc = *(TripleCounts + uWord);
const unsigned uBytes = uSeqCount*sizeof(short);
tc.m_Counts = (unsigned short *) malloc(uBytes);
memset(tc.m_Counts, 0, uBytes);
}
for (unsigned uSeqIndex = 0; uSeqIndex < uSeqCount; ++uSeqIndex)
{
Seq &s = *(v[uSeqIndex]);
const unsigned uSeqLength = s.Length();
for (unsigned uPos = 0; uPos < uSeqLength - 2; ++uPos)
{
const unsigned uLetter1 = CharToLetterEx(s[uPos]);
if (uLetter1 >= 20)
continue;
const unsigned uLetter2 = CharToLetterEx(s[uPos+1]);
if (uLetter2 >= 20)
continue;
const unsigned uLetter3 = CharToLetterEx(s[uPos+2]);
if (uLetter3 >= 20)
continue;
const unsigned uWord = uLetter1 + uLetter2*20 + uLetter3*20*20;
assert(uWord < TRIPLE_COUNT);
TripleCount &tc = *(TripleCounts + uWord);
const unsigned uOldCount = tc.m_Counts[uSeqIndex];
if (0 == uOldCount)
++(tc.m_uSeqCount);
++(tc.m_Counts[uSeqIndex]);
}
}
#if TRACE
{
Log("TripleCounts\n");
unsigned uGrandTotal = 0;
for (unsigned uWord = 0; uWord < TRIPLE_COUNT; ++uWord)
{
const TripleCount &tc = *(TripleCounts + uWord);
if (0 == tc.m_uSeqCount)
continue;
const unsigned uLetter3 = uWord/(20*20);
const unsigned uLetter2 = (uWord - uLetter3*20*20)/20;
const unsigned uLetter1 = uWord%20;
Log("Word %6u %c%c%c %6u",
uWord,
LetterToCharAmino(uLetter1),
LetterToCharAmino(uLetter2),
LetterToCharAmino(uLetter3),
tc.m_uSeqCount);
unsigned uSeqCountWithThisWord = 0;
for (unsigned uSeqIndex = 0; uSeqIndex < uSeqCount; ++uSeqIndex)
{
const unsigned uCount = tc.m_Counts[uSeqIndex];
if (uCount > 0)
{
++uSeqCountWithThisWord;
Log(" %u=%u", uSeqIndex, uCount);
uGrandTotal += uCount;
}
}
if (uSeqCountWithThisWord != tc.m_uSeqCount)
Log(" *** SQ ERROR *** %u %u", tc.m_uSeqCount, uSeqCountWithThisWord);
Log("\n");
}
unsigned uTotalBySeqLength = 0;
for (unsigned uSeqIndex = 0; uSeqIndex < uSeqCount; ++uSeqIndex)
{
Seq &s = *(v[uSeqIndex]);
const unsigned uSeqLength = s.Length();
uTotalBySeqLength += uSeqLength - 2;
}
//.........这里部分代码省略.........
示例9: ProgressiveAlign
void ProgressiveAlign(const SeqVect &v, const Tree &GuideTree, MSA &a)
{
assert(GuideTree.IsRooted());
#if TRACE
Log("GuideTree:\n");
GuideTree.LogMe();
#endif
const unsigned uSeqCount = v.Length();
const unsigned uNodeCount = 2*uSeqCount - 1;
ProgNode *ProgNodes = new ProgNode[uNodeCount];
unsigned uJoin = 0;
unsigned uTreeNodeIndex = GuideTree.FirstDepthFirstNode();
SetProgressDesc("Align node");
do
{
if (GuideTree.IsLeaf(uTreeNodeIndex))
{
if (uTreeNodeIndex >= uNodeCount)
Quit("TreeNodeIndex=%u NodeCount=%u\n", uTreeNodeIndex, uNodeCount);
ProgNode &Node = ProgNodes[uTreeNodeIndex];
unsigned uId = GuideTree.GetLeafId(uTreeNodeIndex);
if (uId >= uSeqCount)
Quit("Seq index out of range");
const Seq &s = *(v[uId]);
Node.m_MSA.FromSeq(s);
Node.m_MSA.SetSeqId(0, uId);
Node.m_uLength = Node.m_MSA.GetColCount();
}
else
{
Progress(uJoin, uSeqCount - 1);
++uJoin;
const unsigned uMergeNodeIndex = uTreeNodeIndex;
ProgNode &Parent = ProgNodes[uMergeNodeIndex];
const unsigned uLeft = GuideTree.GetLeft(uTreeNodeIndex);
const unsigned uRight = GuideTree.GetRight(uTreeNodeIndex);
ProgNode &Node1 = ProgNodes[uLeft];
ProgNode &Node2 = ProgNodes[uRight];
PWPath Path;
AlignTwoMSAs(Node1.m_MSA, Node2.m_MSA, Parent.m_MSA, Path);
Parent.m_uLength = Parent.m_MSA.GetColCount();
Node1.m_MSA.Clear();
Node2.m_MSA.Clear();
}
uTreeNodeIndex = GuideTree.NextDepthFirstNode(uTreeNodeIndex);
}
while (NULL_NEIGHBOR != uTreeNodeIndex);
ProgressStepsDone();
unsigned uRootNodeIndex = GuideTree.GetRootNodeIndex();
const ProgNode &RootProgNode = ProgNodes[uRootNodeIndex];
a.Copy(RootProgNode.m_MSA);
delete[] ProgNodes;
ProgNodes = 0;
}
示例10: ProgAlignSubFams
void ProgAlignSubFams()
{
MSA msaOut;
SetOutputFileName(g_pstrOutFileName.get());
SetInputFileName(g_pstrInFileName.get());
SetMaxIters(g_uMaxIters.get());
SetSeqWeightMethod(g_SeqWeight1.get());
TextFile fileIn(g_pstrInFileName.get());
SeqVect v;
v.FromFASTAFile(fileIn);
const unsigned uSeqCount = v.Length();
if (0 == uSeqCount)
Quit("No sequences in input file");
ALPHA Alpha = ALPHA_Undefined;
switch (g_SeqType.get())
{
case SEQTYPE_Auto:
Alpha = v.GuessAlpha();
break;
case SEQTYPE_Protein:
Alpha = ALPHA_Amino;
break;
case SEQTYPE_DNA:
Alpha = ALPHA_DNA;
break;
case SEQTYPE_RNA:
Alpha = ALPHA_RNA;
break;
default:
Quit("Invalid seq type");
}
SetAlpha(Alpha);
v.FixAlpha();
PTR_SCOREMATRIX UserMatrix = 0;
if (0 != g_pstrMatrixFileName.get())
{
const char *FileName = g_pstrMatrixFileName.get();
const char *Path = getenv("MUSCLE_MXPATH");
if (Path != 0)
{
size_t n = strlen(Path) + 1 + strlen(FileName) + 1;
char *NewFileName = new char[n];
sprintf(NewFileName, "%s/%s", Path, FileName);
FileName = NewFileName;
}
TextFile File(FileName);
UserMatrix = ReadMx(File);
g_Alpha = ALPHA_Amino;
g_PPScore = PPSCORE_SP;
}
SetPPScore();
if (0 != UserMatrix)
g_ptrScoreMatrix = UserMatrix;
if (ALPHA_DNA == Alpha || ALPHA_RNA == Alpha)
{
SetPPScore(PPSCORE_SPN);
g_Distance1.get() = DISTANCE_Kmer4_6;
}
unsigned uMaxL = 0;
unsigned uTotL = 0;
for (unsigned uSeqIndex = 0; uSeqIndex < uSeqCount; ++uSeqIndex)
{
unsigned L = v.GetSeq(uSeqIndex).Length();
uTotL += L;
if (L > uMaxL)
uMaxL = L;
}
SetIter(1);
g_bDiags.get() = g_bDiags1.get();
SetSeqStats(uSeqCount, uMaxL, uTotL/uSeqCount);
SetMuscleSeqVect(v);
MSA::SetIdCount(uSeqCount);
// Initialize sequence ids.
// From this point on, ids must somehow propogate from here.
for (unsigned uSeqIndex = 0; uSeqIndex < uSeqCount; ++uSeqIndex)
v.SetSeqId(uSeqIndex, uSeqIndex);
if (uSeqCount > 1)
MHackStart(v);
if (0 == uSeqCount)
{
//.........这里部分代码省略.........