Skip to content

Commit

Permalink
revise to create new node for each paralgous instance
Browse files Browse the repository at this point in the history
  • Loading branch information
glennhickey committed Mar 21, 2013
1 parent f66d987 commit 9ef0435
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# order is important, libraries first
modules = api stats randgen validate mutations maf liftover extract fasta chain alignability
modules = api stats randgen validate mutations maf liftover extract fasta chain alignability lod

.PHONY: all %.all clean %.clean doxy %.doxy

Expand Down
4 changes: 3 additions & 1 deletion lod/impl/halLodAdjTable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ LodAdjTable::~LodAdjTable()
clear();
}

void LodAdjTable::addNode(LodNode* node, ColumnIteratorConstPtr colIt)

bool LodAdjTable::addNode(LodNode* node, ColumnIteratorConstPtr colIt)
{
const ColumnIterator::ColumnMap* colMap = colIt->getColumnMap();
ColumnIterator::ColumnMap::const_iterator colMapIt = colMap->begin();
Expand Down Expand Up @@ -53,6 +54,7 @@ void LodAdjTable::addNode(LodNode* node, ColumnIteratorConstPtr colIt)
}
}
}
return true;
}

void LodAdjTable::writeAdjacenciesIntoNodes()
Expand Down
39 changes: 34 additions & 5 deletions lod/impl/halLodGraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,21 +87,50 @@ void LodGraph::scanGenome(const Genome* genome, NodeList* nodeList)
{
const Sequence* sequence = seqIt->getSequence();
hal_size_t len = sequence->getSequenceLength();
hal_index_t seqStart = sequence->getStartPosition();

for (hal_index_t pos = 0; pos < (hal_index_t)len; pos += (hal_index_t)_step)
{
// clamp to last position
if (pos > 0 && pos + (hal_index_t)_step >= (hal_index_t)len)
{
pos = (hal_index_t)len - 1;
}

}
// better to move column iterator rather than getting each time?
ColumnIteratorConstPtr colIt = sequence->getColumnIterator(&tgtSet, 0,
pos);
// convert pos to genome coordinate
LodNode* node = new LodNode(sequence, seqStart + pos, seqStart + pos);
_adjTable.addNode(node, colIt);
createColumn(colIt, nodeList);
}
}
}

void LodGraph::createColumn(ColumnIteratorConstPtr colIt, NodeList* nodeList)
{
const Genome* refGenome = colIt->getReferenceGenome();
const ColumnIterator::ColumnMap* colMap = colIt->getColumnMap();
ColumnIterator::ColumnMap::const_iterator colMapIt = colMap->begin();
for (; colMapIt != colMap->end(); ++colMapIt)
{
// add a new node for every palagous base in the reference genome
if (colMapIt->first->getGenome() == refGenome)
{
const ColumnIterator::DNASet* dnaSet = colMapIt->second;
const Sequence* sequence = colMapIt->first;
ColumnIterator::DNASet::const_iterator dnaIt = dnaSet->begin();
for (; dnaIt != dnaSet->end(); ++dnaIt)
{
LodNode* node = new LodNode(sequence, (*dnaIt)->getArrayIndex(),
(*dnaIt)->getArrayIndex());
bool added = _adjTable.addNode(node, colIt);
if (added == true)
{
nodeList->push_back(node);
}
else
{
delete node;
}
}
}
}
}
8 changes: 5 additions & 3 deletions lod/inc/halLodAdjTable.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,12 @@ class LodAdjTable
LodAdjTable();
~LodAdjTable();

/** Add a new node (which has already been created) to the
/** Add a new node (which has already been created) to the
* adjacency table, using the column iterator to resolve all
* its homologous positions. */
void addNode(LodNode* node, ColumnIteratorConstPtr colIt);
* its homologous positions. Returns true if the node was
* added. False if it was filtered out due to some to-be-determined
* optimization criteria. */
bool addNode(LodNode* node, ColumnIteratorConstPtr colIt);

/** For every sequence, for every pair of adjacent node refs,
* add an edge connecting the two nodes */
Expand Down
3 changes: 3 additions & 0 deletions lod/inc/halLodGraph.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,10 @@ class LodGraph

void erase();
void scanGenome(const Genome* genome, NodeList* nodeList);
void createColumn(ColumnIteratorConstPtr colIt, NodeList* nodeList);

protected:


// input alignment structure
AlignmentConstPtr _alignment;
Expand Down

0 comments on commit 9ef0435

Please sign in to comment.