63 CDense_diag::TIds::iterator
i;
65 if (seqAlign.NotEmpty()) {
67 IdsSet = DenDiag->GetIds();
68 }
else if (seqAlign->GetSegs().IsDenseg()) {
69 IdsSet = seqAlign->GetSegs().GetDenseg().GetIds();
87 unsigned int index = (onMaster) ? 0 : 1;
91 ddIt = sa->
SetSegs().SetDendiag().begin();
92 ddEnd = sa->
SetSegs().SetDendiag().end();
93 for (; ddIt != ddEnd; ++ddIt) {
94 if ((*ddIt)->GetDim() != 2 || (*ddIt)->GetIds().size() != 2) {
102 ddIt = sa->
SetSegs().SetDendiag().begin();
103 ddEnd = sa->
SetSegs().SetDendiag().end();
105 for (; ddIt != ddEnd; ++ddIt) {
106 ids = (*ddIt)->SetIds();
107 ids[index]->Assign(*newSeqId);
137 CDense_diag::TStarts::const_iterator k;
138 int Start,
Len, OtherStart;
143 ddend = ddlist->end();
144 for (
i=ddlist->begin();
i!=ddend;
i++) {
145 k = (*i)->GetStarts().begin();
146 Len = (*i)->GetLen();
149 k = (*i)->GetStarts().begin();
152 if ((Position >= Start) && (Position < (Start+
Len))) {
153 return(OtherStart + (Position-Start));
190 iend = pDenDiagSet->end();
191 for (
i=pDenDiagSet->begin();
i!=iend;
i++) {
192 start = (onMaster) ? (*i)->GetStarts().front() : (*i)->GetStarts().back();
193 stop = start + (*i)->GetLen() - 1;
194 if (Position >= start && Position <= stop) {
206 int nBlocks, position;
208 vector<int> align1Blocks, align1Starts;
210 alignedPositions.clear();
215 if (
GetSeqID(align1, align1Id, !onMaster) &&
GetSeqID(align2, align2Id, !onMaster) &&
222 nBlocks = align1Blocks.size();
223 for (
int i = 0;
i < nBlocks; ++
i) {
224 position = align1Starts[
i];
225 for (
int j = 0; j < align1Blocks[
i]; ++j) {
227 alignedPositions.push_back(position);
234 return alignedPositions.size();
243 if (seqAlign.
Empty()) {
250 for (
i=pDenDiagSet->begin();
i!=pDenDiagSet->end();
i++) {
251 Len += (*i)->GetLen();
261 if (seqAlign.
Empty()) {
267 lowerBound = (onMaster) ? pDenDiagSet->front()->GetStarts().front() : pDenDiagSet->front()->GetStarts().back();
275 if (seqAlign.
Empty()) {
281 upperBound = (onMaster) ? pDenDiagSet->back()->GetStarts().front() : pDenDiagSet->back()->GetStarts().back();
282 upperBound += pDenDiagSet->back()->GetLen() - 1;
293 int alignedResCtr = 0;
294 int start = -1, stop = -1;
297 if (align.
Empty() || sequenceString.size() < 1) {
302 if (length < 1 || (
int) sequenceString.size() < length) {
307 pAlignedRes =
new char[length];
308 if (!pAlignedRes)
return;
314 start = (isMaster) ? ddFirst->GetStarts().front() : ddFirst->GetStarts().back();
315 stop = (isMaster) ? ddLast->GetStarts().front() : ddLast->GetStarts().back();
316 stop += ddLast->GetLen() - 1;
324 if (start >=0 && start <= stop && stop < (
int) sequenceString.size()) {
325 for (
int i = start;
i <= stop; ++
i) {
328 pAlignedRes[alignedResCtr] = sequenceString[
i];
336 if (alignedResCtr != length) {
351 vector<int>* starts, vector<int>* lengths) {
354 vector<int> vstarts, vlengths;
357 if (vlengths.size() == vstarts.size()) {
358 nBlocks = vstarts.size();
359 while (
i < nBlocks &&
result < 0) {
360 if (residue >= vstarts[
i] && residue < vstarts[
i] + vlengths[
i]) {
365 if (starts !=
NULL) {
366 starts->insert(starts->begin(), vstarts.begin(), vstarts.end());
368 if (lengths !=
NULL) {
369 lengths->insert(lengths->begin(), vlengths.begin(), vlengths.end());
380 if (seqAlign.
Empty()) {
397 if (seqAlign.
NotEmpty() && nBlocks > 0) {
400 for (cit = pDenDiagSet->begin(); cit != pDenDiagSet->end(); ++cit) {
401 lengths.push_back((*cit)->GetLen());
406 count = (count == nBlocks) ? count: 0;
425 if (seqAlign.
NotEmpty() && nBlocks > 0) {
428 for (cit = pDenDiagSet->begin(); cit != pDenDiagSet->end(); ++cit) {
429 start = (onMaster) ? (*cit)->GetStarts().front() : (*cit)->GetStarts().back();
430 starts.push_back(start);
435 count = (count == nBlocks) ? count: 0;
449 if (align.
SetSegs().IsDendiag()) {
450 dd = &(align.
SetSegs().SetDendiag());
467 k = pDenDiagSet->begin();
470 k = pDenDiagSet->end();
485 CDense_diag::TIds::iterator
i;
490 k = pDenDiagSet->begin();
491 IdsSet = (*k)->GetIds();
497 for (; k != pDenDiagSet->end(); k++, iii++)
499 IdsSet = (*k)->GetIds();
526 if (pDD && pAl->
IsInt()) {
532 RefID = &interval.
SetId();
536 CPacked_seqint::Tdata::iterator s;
539 from=(*s)->GetFrom();
542 RefID = &((*s)->SetId());
552 CDense_diag::TStarts::const_iterator pos;
553 vector < CRef< CSeq_id > >::const_iterator pid;
555 for (iDst=0,pp=pDD->begin(); pp!=pDD->end(); pp++,iDst++){
556 pos=(*pp)->GetStarts().begin();
559 pid=(*pp)->GetIds().begin();
564 pAl->
SetInt().SetFrom(posStart);
566 pAl->
SetInt().SetId(*SeqID);
573 intrvl->
SetId(*SeqID);
583 idMaster.
Reset(seqID1);
591 newDD->SetIds().push_back(idMaster);
592 newDD->SetIds().push_back(idSeq);
593 newDD->SetStarts().push_back(st1);
594 newDD->SetStarts().push_back(st2);
596 pDD->push_back(newDD);
610 list< CRef< CSeq_align > >::const_iterator j;
619 if (++Count == Row)
break;
622 if ((*j)->GetSegs().IsDendiag()) {
624 pDenDiagSet = &((*j)->GetSegs().GetDendiag());
636 list< CRef< CSeq_align > >::iterator j;
640 if (Row == 0) j = seqAnnot->
SetData().SetAlign().begin();
643 for (j= seqAnnot->
SetData().SetAlign().begin();
644 j!= seqAnnot->
SetData().SetAlign().end(); j++) {
645 if (++Count == Row)
break;
648 if ((*j)->SetSegs().IsDendiag()) {
650 pDenDiagSet = &((*j)->SetSegs().SetDendiag());
662 list< CRef< CSeq_align > >::iterator j, jend;
665 if (RowIndex == 0)
return(
false);
669 jend = seqAnnot->
SetData().SetAlign().end();
670 for (j= seqAnnot->
SetData().SetAlign().begin(); j != jend; j++) {
671 if (RowCount == RowIndex) {
672 seqAnnot->
SetData().SetAlign().erase(j);
676 if (RowCount > RowIndex)
break;
685 if (seqAlign.
Empty())
692 if (saList.begin() != saList.end())
706 newSa->
Assign(*denseSegSeqAlign);
711 newSa->
SetSegs().SetDendiag() = ddList;
730 int total = numrows * numsegs;
735 bool strands_exist = ((
int) strands.size() == total);
736 bool scores_exist = ((
int) scores.size() == total);
741 dd->SetLen(lens[seg]);
746 dd->SetIds().push_back(ids[
row]);
747 dd->SetStarts().push_back(start);
749 dd->SetStrands().push_back(strands[pos]);
752 dd->SetScores().push_back(scores[pos]);
757 if (rows_per_seg >= 2) {
758 dd->SetDim(rows_per_seg);
767 list <CRef <CUpdate_align> > ::iterator pPen;
771 CSeq_align * pAl = *((*pPen)->SetSeqannot().SetData().SetAlign().begin());
773 vector < CRef< CSeq_id > >::const_iterator pid=pDDPen->
GetIds().begin();
789 if (seqAlign.
Empty()) {
790 err =
"GetPssmIdFromSeqAlign: Empty Seq_align.\n";
792 err =
"GetPssmIdFromSeqAlign: Only Seq_aligns with dim = 2 supported.\n";
797 err =
"GetPssmIdFromSeqAlign: Dense_diags not currently supported.\n";
799 err.append(
"GetPssmIdFromSeqAlign: Seq_align is an unsupported type (%d).\n", seqAlign->
GetType());
811 if (seqAlign.
Empty()) {
812 err =
"GetMasterGIFromSeqAlign: Empty Seq_align.\n";
818 err =
"GetMasterGIFromSeqAlign: Dense_seg's master sequence is empty or not of type 'GI'.\n";
825 err =
"GetMasterGIFromSeqAlign: Dense_diag's master sequence is empty or not of type 'GI'.\n";
828 err.append(
"GetMasterGIFromSeqAlign: Seq_align is an unsupported type (%d).\n", seqAlign->
GetType());
User-defined methods of the data storage class.
User-defined methods of the data storage class.
int MapPositionToMaster(int childPos, const CSeq_align &align)
void MakeDDFromSeqLoc(CSeq_loc *pAl, TDendiag *pDD)
void MakeSeqLocFromDD(const TDendiag *pDD, CSeq_loc *pAl)
TGi GetMasterGIFromSeqAlign(const CRef< CSeq_align > &seqAlign, string &err)
int GetLowerBound(const CRef< CSeq_align > &seqAlign, bool onMaster)
CRef< CSeq_align > ExtractFirstSeqAlign(CRef< CSeq_align > seqAlign)
bool GetDenDiagSet(const CRef< CSeq_annot > &seqAnnot, int Row, const TDendiag *&pDenDiagSet)
bool CheckSeqIdInDD(const CRef< CSeq_align > &seqAlign)
bool ChangeSeqIdInSeqAlign(CRef< CSeq_align > &sa, const CRef< CSeq_id > &newSeqId, bool onMaster)
int GetAlignedPositions(const CRef< CSeq_align > &align1, const CRef< CSeq_align > &align2, vector< int > &alignedPositions, bool onMaster)
int GetBlockStartsForMaster(const CRef< CSeq_align > &seqAlign, vector< int > &starts)
CRef< CSeq_align > Denseg2DenseDiagList(const CRef< CSeq_align > &denseSegSeqAlign)
int GetBlockNumberForResidue(int residue, const CRef< CSeq_align > &seqAlign, bool onMaster, vector< int > *starts, vector< int > *lengths)
int GetBlockCount(const CRef< CSeq_align > &seqAlign)
bool GetSeqID(const CRef< CSeq_align > &seqAlign, CRef< CSeq_id > &SeqID, bool getSlave)
bool SetDenDiagSet(CRef< CSeq_annot > &seqAnnot, int Row, TDendiag *&pDenDiagSet)
int MapPosition(const CSeq_align &seqAlign, int Position, CoordMapDir mapDir)
void SetAlignedResiduesOnSequence(const CRef< CSeq_align > &align, const string &sequenceString, char *&pAlignedRes, bool isMaster)
bool IsPositionAligned(const CSeq_align &seqAlign, int Position, bool onMaster)
void AddIntervalToDD(TDendiag *pDD, CRef< CSeq_id > seqID1, CRef< CSeq_id > seqID2, TSeqPos st1, TSeqPos st2, TSeqPos lll)
int GetNumAlignedResidues(const CRef< CSeq_align > &seqAlign)
int GetBlockLengths(const CRef< CSeq_align > &seqAlign, vector< int > &lengths)
bool GetFirstOrLastDenDiag(const CRef< CSeq_align > &seqAlign, bool First, CRef< CDense_diag > &DenDiag)
bool GetPendingSeqId(CCdCore *pCD, int irow, CRef< CSeq_id > &seqID)
int MapPositionToChild(int masterPos, const CSeq_align &align)
int GetBlockStarts(const CRef< CSeq_align > &seqAlign, vector< int > &starts, bool onMaster)
int GetUpperBound(const CRef< CSeq_align > &seqAlign, bool onMaster)
int GetPssmIdFromSeqAlign(const CRef< CSeq_align > &seqAlign, string &err)
bool GetDDSetFromSeqAlign(const CSeq_align &align, const TDendiag *&dd)
bool EraseRow(CRef< CSeq_annot > &seqAnnot, int RowIndex)
TDendiag::const_iterator TDendiag_cit
CSeq_align::C_Segs::TDendiag TDendiag
TDendiag::iterator TDendiag_it
const int INVALID_POSITION
bool SeqIdsMatch(const CRef< CSeq_id > &id1, const CRef< CSeq_id > &id2)
int GetCDDPssmIdFromSeqId(const CRef< CSeq_id > &id)
unsigned int TSeqPos
Type for sequence locations and lengths.
int TSignedSeqPos
Type for signed sequence position.
virtual void Assign(const CSerialObject &source, ESerialRecursionMode how=eRecursive)
Set object to copy of another one.
void SetPacked_int(TPacked_int &v)
void Reset(void)
Reset reference object.
bool NotEmpty(void) const THROWS_NONE
Check if CRef is not empty – pointing to an object and has a non-null value.
bool Empty(void) const THROWS_NONE
Check if CRef is empty – not pointing to any object, which means having a null value.
#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.
TPending & SetPending(void)
Assign a value to Pending data member.
const TDenseg & GetDenseg(void) const
Get the variant data.
bool CanGet(void) const
Check if it is safe to call Get method.
const TStarts & GetStarts(void) const
Get the Starts member data.
TDim GetDim(void) const
Get the Dim member data.
void SetSegs(TSegs &value)
Assign a value to Segs data member.
vector< ENa_strand > TStrands
const TLens & GetLens(void) const
Get the Lens member data.
vector< TSignedSeqPos > TStarts
vector< CRef< CSeq_id > > TIds
vector< CRef< CSeq_id > > TIds
const TIds & GetIds(void) const
Get the Ids member data.
bool IsDendiag(void) const
Check if variant Dendiag is selected.
TDim GetDim(void) const
Get the Dim member data.
const TDendiag & GetDendiag(void) const
Get the variant data.
bool IsDisc(void) const
Check if variant Disc is selected.
TType GetType(void) const
Get the Type member data.
bool IsSetDim(void) const
dimensionality Check if a value has been assigned to Dim data member.
const TIds & GetIds(void) const
Get the Ids member data.
vector< CRef< CScore > > TScores
TNumseg GetNumseg(void) const
Get the Numseg member data.
const TScores & GetScores(void) const
Get the Scores member data.
const TDisc & GetDisc(void) const
Get the variant data.
const TStrands & GetStrands(void) const
Get the Strands member data.
const Tdata & Get(void) const
Get the member data.
const TSegs & GetSegs(void) const
Get the Segs member data.
bool IsDenseg(void) const
Check if variant Denseg is selected.
void SetTo(TTo value)
Assign a value to To data member.
void SetId(TId &value)
Assign a value to Id data member.
void SetFrom(TFrom value)
Assign a value to From data member.
TGi GetGi(void) const
Get the variant data.
bool IsPacked_int(void) const
Check if variant Packed_int is selected.
bool IsGi(void) const
Check if variant Gi is selected.
bool IsInt(void) const
Check if variant Int is selected.
bool IsAlign(void) const
Check if variant Align is selected.
void SetData(TData &value)
Assign a value to Data data member.
const TAlign & GetAlign(void) const
Get the variant data.
const TData & GetData(void) const
Get the Data member data.
unsigned int
A callback function used to compare two keys in a database.
#define row(bind, expected)