virtual void initializeThird() { for(std::vector<Species*>::const_iterator i(theProcessSpecies.begin()); i != theProcessSpecies.end(); ++i) { if((*i)->getIsDiffusing()) { THROW_EXCEPTION(ValueError, String(getPropertyInterface().getClassName()) + "[" + getFullID().asString() + "]: All polymer subunit species must be" + " immobile. " + (*i)->getVariable()->getFullID().asString() + " is a diffusing species."); } if((*i)->getIsVolume()) { THROW_EXCEPTION(ValueError, String(getPropertyInterface().getClassName()) + "[" + getFullID().asString() + "]: All polymer subunit species must be on a " + "surface. " + (*i)->getVariable()->getFullID().asString() + " is a volume species."); } } }
virtual void initialize() { if(isInitialized) { return; } ReactionProcess::initialize(); isPriorityQueued = true; if(getOrder() != 1 && getOrder() != 2) { THROW_EXCEPTION(ValueError, String(getPropertyInterface().getClassName()) + "[" + getFullID().asString() + "]: This PolymerFragmentationProcess requires " + "two substrates."); } if(p == -1) { p = k; } else { k = p; } }
void setSpatiocyteStepper() { Model::StepperMap aStepperMap(getModel()->getStepperMap()); for(Model::StepperMap::const_iterator i(aStepperMap.begin()); i != aStepperMap.end(); ++i ) { theSpatiocyteStepper = dynamic_cast<SpatiocyteStepper*>(i->second); if(theSpatiocyteStepper) { return; } } THROW_EXCEPTION(ValueError, getPropertyInterface().getClassName() + ": " + getFullID().asString() + " SpatiocyteStepper has not been declared."); }
void MoleculePopulateProcess::populateUniformOnDiffuseVacant(Species* aSpecies) { std::cout << " Populating:" << getIDString(aSpecies) << std::endl; if(!aSpecies->getIsPopulated()) { if(UniformRadiusX == 1 && UniformRadiusY == 1 && UniformRadiusZ == 1 && !OriginX && !OriginY && !OriginZ) { Species* aVacantSpecies(aSpecies->getVacantSpecies()); aVacantSpecies->updateDiffuseVacantMolecules(); unsigned int aSize(aSpecies->getPopulateMoleculeSize()); if(aVacantSpecies->size() < aSize) { THROW_EXCEPTION(ValueError, String( getPropertyInterface().getClassName()) + "[" + getFullID().asString() + "]: There are " + int2str(aSize) + " " + getIDString(aSpecies) + " molecules that must be uniformly populated," + "\nbut there are only " + int2str(aVacantSpecies->size()) + " diffuse vacant voxels of " + getIDString(aSpecies->getVacantSpecies()) + " that can be populated on."); } for(unsigned int i(0); i != aSize; ++i) { Voxel* aMolecule(aVacantSpecies->getRandomMolecule()); aVacantSpecies->softRemoveMolecule(aMolecule); aSpecies->addMolecule(aMolecule); } } else { populateUniformRanged(aSpecies); } aSpecies->setIsPopulated(); } }
virtual void initialize() { if(isInitialized) { return; } SpatiocyteProcess::initialize(); for(VariableReferenceVector::iterator i(theVariableReferenceVector.begin()); i != theVariableReferenceVector.end(); ++i) { Species* aSpecies(theSpatiocyteStepper->variable2species( (*i).getVariable())); if((*i).getCoefficient()) { if((*i).getCoefficient() == -1) { if(theVacantSpecies) { THROW_EXCEPTION(ValueError, String( getPropertyInterface().getClassName()) + "[" + getFullID().asString() + "]: A MicrotubuleProcess requires only " + "one vacant variable reference with -1 " + "coefficient as the vacant species of " + "the microtubule compartment, but " + getIDString(theVacantSpecies) + " and " + getIDString(aSpecies) + " are given."); } theVacantSpecies = aSpecies; } else if((*i).getCoefficient() == -2) { if(theMinusSpecies) { THROW_EXCEPTION(ValueError, String( getPropertyInterface().getClassName()) + "[" + getFullID().asString() + "]: A MicrotubuleProcess requires only " + "one variable reference with -2 " + "coefficient as the minus end species " + "of the microtubule compartment, but " + getIDString(theMinusSpecies) + " and " + getIDString(aSpecies) + " are given."); } theMinusSpecies = aSpecies; } else if((*i).getCoefficient() == -3) { if(thePlusSpecies) { THROW_EXCEPTION(ValueError, String( getPropertyInterface().getClassName()) + "[" + getFullID().asString() + "]: A MicrotubuleProcess requires only " + "one variable reference with -3 " + "coefficient as the plus end species " + "of the microtubule compartment, but " + getIDString(thePlusSpecies) + " and " + getIDString(aSpecies) + " are given."); } thePlusSpecies = aSpecies; } } else { theKinesinSpecies.push_back(aSpecies); } } if(!theKinesinSpecies.size()) { THROW_EXCEPTION(ValueError, String( getPropertyInterface().getClassName()) + "[" + getFullID().asString() + "]: A MicrotubuleProcess requires at least one " + "nonHD variable reference with zero coefficient " + "as the kinesin species, but none is given."); } if(!theVacantSpecies) { THROW_EXCEPTION(ValueError, String( getPropertyInterface().getClassName()) + "[" + getFullID().asString() + "]: A MicrotubuleProcess requires one " + "nonHD variable reference with negative " + "coefficient as the vacant species, " + "but none is given."); } if(!theMinusSpecies) { theMinusSpecies = theVacantSpecies; } if(!thePlusSpecies) { thePlusSpecies = theVacantSpecies; } VoxelDiameter = theSpatiocyteStepper->getVoxelRadius()*2; DimerPitch /= VoxelDiameter; Length /= VoxelDiameter; MonomerPitch /= VoxelDiameter; Radius /= VoxelDiameter; theVacantSpecies->setIsOffLattice(); theMinusSpecies->setIsOffLattice(); thePlusSpecies->setIsOffLattice(); for(unsigned int i(0); i != theKinesinSpecies.size(); ++i) { theKinesinSpecies[i]->setIsOffLattice(); } }
String Entity::asString() const { return getPropertyInterface().getClassName() + "[" + ( theSuperSystem ? getFullID().asString(): "unbound: " + getID() ) + "]"; }
void MoleculePopulateProcess::populateUniformRanged(Species* aSpecies) { Comp* aComp(aSpecies->getComp()); double delta(0); // Increase the compartment dimensions by delta if it is a surface // compartment: if(aComp->dimension == 2) { delta = 0.1; } double maxX(std::min(1.0, OriginX+UniformRadiusX)); double minX(std::max(-1.0, OriginX-UniformRadiusX)); double maxY(std::min(1.0, OriginY+UniformRadiusY)); double minY(std::max(-1.0, OriginY-UniformRadiusY)); double maxZ(std::min(1.0, OriginZ+UniformRadiusZ)); double minZ(std::max(-1.0, OriginZ-UniformRadiusZ)); maxX = aComp->centerPoint.x + maxX*aComp->lengthX/2*(1+delta); minX = aComp->centerPoint.x + minX*aComp->lengthX/2*(1+delta); maxY = aComp->centerPoint.y + maxY*aComp->lengthY/2*(1+delta); minY = aComp->centerPoint.y + minY*aComp->lengthY/2*(1+delta); maxZ = aComp->centerPoint.z + maxZ*aComp->lengthZ/2*(1+delta); minZ = aComp->centerPoint.z + minZ*aComp->lengthZ/2*(1+delta); std::vector<unsigned int> aCoords; for(std::vector<unsigned int>::iterator i(aComp->coords.begin()); i != aComp->coords.end(); ++i) { Voxel* aVoxel(theSpatiocyteStepper->coord2voxel(*i)); Point aPoint(theSpatiocyteStepper->coord2point(aVoxel->coord)); if(aVoxel->id == aSpecies->getVacantID() && aPoint.x < maxX && aPoint.x > minX && aPoint.y < maxY && aPoint.y > minY && aPoint.z < maxZ && aPoint.z > minZ) { aCoords.push_back(*i); } } unsigned int aSize(aSpecies->getPopulateMoleculeSize()); if(aCoords.size() < aSize) { THROW_EXCEPTION(ValueError, String( getPropertyInterface().getClassName()) + "[" + getFullID().asString() + "]: There are " + int2str(aSize) + " " + getIDString(aSpecies) + " molecules that must be uniformly populated in a " + "given range,\n but there are only " + int2str(aCoords.size()) + " vacant voxels of " + getIDString(aSpecies->getVacantSpecies()) + " that can be populated."); } unsigned int aCoordsArray[aCoords.size()]; for(unsigned int i(0); i != aCoords.size(); ++i) { aCoordsArray[i] = aCoords[i]; } gsl_ran_shuffle(getStepper()->getRng(), aCoordsArray, aCoords.size(), sizeof(unsigned int)); for(unsigned int i(0); i != aSize; ++i) { aSpecies->addMolecule(theSpatiocyteStepper->coord2voxel(aCoordsArray[i])); } }