void MoleculePopulateProcess::populateUniformDense(Species* aSpecies, unsigned int aList[], unsigned int* aCount) { std::cout << " Populating:" << getIDString(aSpecies) << std::endl; Comp* aComp(aSpecies->getComp()); if(!aSpecies->getIsPopulated()) { if(UniformRadiusX == 1 && UniformRadiusY == 1 && UniformRadiusZ == 1 && !OriginX && !OriginY && !OriginZ) { unsigned int aSize(aSpecies->getPopulateMoleculeSize()); for(unsigned int j(0); j != aSize; ++j) { Voxel* aVoxel; do { aVoxel = theSpatiocyteStepper->coord2voxel( aComp->coords[aList[(*aCount)++]]); } while(aVoxel->id != aComp->vacantID); aSpecies->addMolecule(aVoxel); } } else { populateUniformRanged(aSpecies); } aSpecies->setIsPopulated(); } }
void Core::saveConfiguration() { if (QThread::currentThread() != coreThread) return (void) QMetaObject::invokeMethod(this, "saveConfiguration"); if (!isReady()) return; ProfileLocker::assertLock(); QString dir = Settings::getSettingsDirPath(); QDir directory(dir); if (!directory.exists() && !directory.mkpath(directory.absolutePath())) { qCritical() << "Error while creating directory " << dir; return; } QString profile = Settings::getInstance().getCurrentProfile(); if (profile == "") { // no profile active; this should only happen on startup, if at all profile = sanitize(getUsername()); if (profile == "") // happens on creation of a new Tox ID profile = getIDString(); Settings::getInstance().switchProfile(profile); } QString path = directory.filePath(profile + TOX_EXT); saveConfiguration(path); }
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(); } }
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])); } }