Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dead code removal #21

Open
wants to merge 6 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
273 changes: 6 additions & 267 deletions src/NFcore/NFcore.hh

Large diffs are not rendered by default.

58 changes: 7 additions & 51 deletions src/NFcore/complex.cpp
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
#include <iostream>
#include "NFcore.hh"
#include <string>

// for labeling
#include <sstream>
#include <algorithm>
#include "../nauty24/nausparse.h"


using namespace std;
using namespace NFcore;


const int Node::IS_MOLECULE = -1;


Complex::Complex(System * s, int ID_complex, Molecule * m)
: is_canonical( false ), canonical_label("")
{
Expand All @@ -20,10 +20,12 @@ Complex::Complex(System * s, int ID_complex, Molecule * m)
this->complexMembers.push_back(m);
}


Complex::~Complex()
{
}


bool Complex::isAlive() {
if(complexMembers.size()==0) return false;
return (*complexMembers.begin())->isAlive();
Expand All @@ -37,7 +39,6 @@ int Complex::getMoleculeCountOfType(MoleculeType *m)
{
if((*molIter)->getMoleculeTypeName()==m->getName())
{
//cout<<count<<" Match! : "<<m->getName()<<" with "<< (*molIter)->getMoleculeTypeName()<<endl;
count++;
}
}
Expand Down Expand Up @@ -68,39 +69,14 @@ void Complex::printDetailsLong()
cout << "label: " << getCanonicalLabel() << endl;
}

void Complex::getDegreeDistribution(vector <int> &degreeDist)
{
for( molIter = complexMembers.begin(); molIter != complexMembers.end(); molIter++ )
{
int d = (*molIter)->getDegree();
while(d>=(int)degreeDist.size())
degreeDist.push_back(0);
degreeDist.at(d)++;
}
}

void Complex::printDegreeDistribution()
{
vector <int> degreeDist;
vector <int>::iterator degIter;
getDegreeDistribution(degreeDist);
cout<<"Degree Distribution for complex "<< ID_complex<<", size: "<<complexMembers.size()<<endl;
cout<<" Degree:";
for(int d=0; d<(int)degreeDist.size(); d++)
cout<<"\t"<<d;
cout<<endl<<" Count:";
for( degIter = degreeDist.begin(); degIter != degreeDist.end(); degIter++ )
cout<<"\t"<<(*degIter);
cout<<endl;
}


void Complex::refactorToNewComplex(int new_ID_complex)
{
for( molIter = complexMembers.begin(); molIter != complexMembers.end(); molIter++ )
(*molIter)->moveToNewComplex(new_ID_complex);
}


/* for binding, we want to merge a new complex, c, with our complex, this */
void Complex::mergeWithList(Complex * c)
{
Expand All @@ -115,7 +91,6 @@ void Complex::mergeWithList(Complex * c)
}



/* class to decide when a molecule is in the wrong complex (will tell us to delete this molecule
* from this complex */
class IsInWrongComplex
Expand All @@ -128,9 +103,7 @@ class IsInWrongComplex
int ID;
};

//int counter=0;
//int totalSizeSum=0;
//int avgTraversalSize = 0;

/* for unbinding, we have to figure out the elements of the new complex,
* put those elements in the new complex, renumber the complex_id for those
* molecules, and delete those molecules from this complex. wheh! */
Expand All @@ -146,14 +119,6 @@ void Complex::updateComplexMembership(Molecule * m)
list <Molecule *> members;
m->traverseBondedNeighborhood(members, ReactionClass::NO_LIMIT);

//counter++;
//cout<<"traversing neighborhood: "<<counter<<endl;
//totalSizeSum+=members.size();
//avgTraversalSize = totalSizeSum/counter;
//cout<<members.size()<<endl;
//cout<<"average: "<<avgTraversalSize<<endl;


//Check if we even need to create a new complex (if not, return)
if(members.size()==(unsigned)this->getComplexSize())
{
Expand All @@ -162,9 +127,7 @@ void Complex::updateComplexMembership(Molecule * m)
}

//Get the next available complex
// NETGEN -- redirected call to ComplexList object at system->allComplexes
Complex *newComplex = (system->getAllComplexes()).getNextAvailableComplex();
//cout<<" forming new complex: next available: " <<newComplex->getComplexID()<<endl;

//renumber our complex elements
list <Molecule *>::iterator molIter;
Expand All @@ -174,17 +137,11 @@ void Complex::updateComplexMembership(Molecule * m)

//put our new complex elements into that complex
newComplex->complexMembers.splice(newComplex->complexMembers.end(),members);
//cout<<"size of list now: " << members.size() <<endl;

//remove all molecules from this that don't have the correct complex id
complexMembers.remove_if(IsInWrongComplex(this->ID_complex));



//update new complex in reactions?

//

//done!
}

Expand Down Expand Up @@ -442,4 +399,3 @@ void Complex::generateCanonicalLabel ( )
canonical_label = labelstream.str();
is_canonical = true;
}

46 changes: 2 additions & 44 deletions src/NFcore/complexList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@

#include "NFcore.hh"
#include <math.h>
//#include <fstream>
//#include "../NFscheduler/NFstream.h"
//#include "../NFscheduler/Scheduler.h"


using namespace std;
using namespace NFcore;
Expand Down Expand Up @@ -42,7 +40,6 @@ ComplexList::~ComplexList()
// createComplex
// getNextAvailableComplex
// notifyThatComplexIsAvailable

int ComplexList::createComplex(Molecule * m)
{
if (!useComplex) return -1; //Only create complexes if we intend on using them...
Expand All @@ -65,30 +62,12 @@ Complex * ComplexList::getNextAvailableComplex()
}



void ComplexList::notifyThatComplexIsAvailable(int ID_complex)
{
nextAvailableComplex.push(ID_complex);
}






void ComplexList::purgeAndPrintAvailableComplexList()
{
cout << "AvailableComplexes:";
while( !nextAvailableComplex.empty() )
{
cout << " -> " << nextAvailableComplex.front();
nextAvailableComplex.pop();
}
cout << endl;
}



void ComplexList::printAllComplexes()
{
cout<<"All System Complexes:"<<endl;
Expand All @@ -99,21 +78,6 @@ void ComplexList::printAllComplexes()
}



void ComplexList::outputComplexSizes(double cSampleTime)
{
int size = 0;
(sys->getOutputFileStream())<<"\t"<<cSampleTime;
for( complexIter = allComplexes.begin(); complexIter != allComplexes.end(); complexIter++ )
{
size = (*complexIter)->getComplexSize();
if (size!=0) (sys->getOutputFileStream())<<"\t"<<size;
}
(sys->getOutputFileStream())<<endl;
}



double ComplexList::outputMeanCount(MoleculeType *m)
{
int count = 0;
Expand All @@ -129,7 +93,7 @@ double ComplexList::outputMeanCount(MoleculeType *m)
if(size>=1) { allSum += size; allCount++; }

}
//cout<<sum<<"/"<<count<<" "<<allSum<<"/"<<allCount<<endl;

if(count!=0)
{
(sys->getOutputFileStream())<<"\t"<<((double)sum/(double)count)<<endl;
Expand All @@ -145,7 +109,6 @@ double ComplexList::outputMeanCount(MoleculeType *m)
}



double ComplexList::calculateMeanCount(MoleculeType *m)
{
int count = 0;
Expand All @@ -164,7 +127,6 @@ double ComplexList::calculateMeanCount(MoleculeType *m)
}



void ComplexList::outputMoleculeTypeCountPerComplex(MoleculeType *m)
{
int size = 0;
Expand All @@ -180,9 +142,6 @@ void ComplexList::outputMoleculeTypeCountPerComplex(MoleculeType *m)
}



// TODO: figure out how friend functions work!!
// friend functions
template<class T>
NFstream& operator<<(NFstream& nfstream, const T& value)
{
Expand All @@ -193,4 +152,3 @@ NFstream& operator<<(NFstream& nfstream, const T& value)

return nfstream;
}

Loading