int main (void) { linkedList* memoryMap = new linkedList(); // instantiate linkedList memoryMap->create(); // create memory map (add Node) displayMenu(); // print menu to screen do { input = parseUser(); // make sure user is inputting number switch (input) { case 1: addProgram(memoryMap); // add program in MM break; case 2: killProgram(memoryMap); // kill progam in MM break; case 3: getFragments(memoryMap); // get fragements in MM break; case 4: memoryMap -> display(); // display MM break; } while (input != 1 && input != 2 && input != 3 && input != 4 && input != 5) { input = parseUser(); // make sure user is inputting numbers } } while (input == 1 || input == 2 || input == 3 || input == 4); // if input = 5 -> exit Program }
void fingerprint2::getFragments(vector<int> levels, vector<int> curfrag, int level, OBAtom* patom, OBBond* pbond) { //Recursive routine to analyse schemical structure and populate fragset and ringset //Hydrogens,charges(except dative bonds), spinMultiplicity ignored const int Max_Fragment_Size = 7; int bo=0; if(pbond) { bo = pbond->IsAromatic() ? 5 : pbond->GetBO(); // OBAtom* pprevat = pbond->GetNbrAtom(patom); // if(patom->GetFormalCharge() && (patom->GetFormalCharge() == -pprevat->GetFormalCharge())) // ++bo; //coordinate (dative) bond eg C[N+]([O-])=O is seen as CN(=O)=O } curfrag.push_back(bo); curfrag.push_back(patom->GetAtomicNum()); levels[patom->GetIdx()-1] = level; vector<OBEdgeBase*>::iterator itr; OBBond *pnewbond; // PrintFpt(curfrag,(int)patom); for (pnewbond = patom->BeginBond(itr);pnewbond;pnewbond = patom->NextBond(itr)) { if(pnewbond==pbond) continue; //don't retrace steps OBAtom* pnxtat = pnewbond->GetNbrAtom(patom); if(pnxtat->GetAtomicNum() == OBElements::Hydrogen) continue; int atlevel = levels[pnxtat->GetIdx()-1]; if(atlevel) //ring { if(atlevel==1) { //If complete ring (last bond is back to starting atom) add bond at front //and save in ringset curfrag[0] = pnewbond->IsAromatic() ? 5 : pnewbond->GetBO(); ringset.insert(curfrag); curfrag[0] = 0; } } else //no ring { if(level<Max_Fragment_Size) { // TRACE("level=%d size=%d %p frag[0]=%p\n",level, curfrag.size(),&curfrag, &(curfrag[0])); //Do the next atom; levels, curfrag are passed by value and hence copied getFragments(levels, curfrag, level+1, pnxtat, pnewbond); } } } //do not save C,N,O single atom fragments if(curfrag[0]==0 && (level>1 || patom->GetAtomicNum()>8 || patom->GetAtomicNum()<6)) { fragset.insert(curfrag); //curfrag ignored if an identical fragment already present // PrintFpt(curfrag,level); } }
FastServer( std::vector<std::string> const & rfilenames, std::vector< ::libmaus::fastx::FastInterval > const & rintervals, std::string const & shostname, unsigned short rport = 4444, unsigned int const backlog = 128) : filenames(rfilenames), fragments(getFragments(filenames)), intervals(rintervals), port(rport), seso(UNIQUE_PTR_MOVE(server_socket_type::allocateServerSocket(port,backlog,shostname.c_str(),32*1024))), intervalserver(false) { }
Node* CylinderSurfaceModule::evaluate(Context* ctx) { NumberValue* heightValue = dynamic_cast<NumberValue*>(getParameterArgument(ctx,0)); double h=1.0; if(heightValue) h=heightValue->getNumber(); NumberValue* rValue = dynamic_cast<NumberValue*>(getParameterArgument(ctx,1)); double r=1.0; if(rValue) r=rValue->getNumber(); Value* centerValue=getParameterArgument(ctx,2); bool center=false; if(centerValue) center=centerValue->isTrue(); double z1,z2; if(center) { z1 = -h/2; z2 = +h/2; } else { z1 = 0.0; z2 = h; } int f = getFragments(r,ctx); Polygon c1 = getCircle(r,f,z1); Polygon c2 = getCircle(r,f,z2); PrimitiveNode* p = new PrimitiveNode(); for(int i=0; i<f; i++) { int j=(i+1)%f; p->createPolygon(); p->appendVertex(c1.at(i)); p->appendVertex(c2.at(i)); p->appendVertex(c2.at(j)); p->appendVertex(c1.at(j)); } return p; }
bool fingerprint2::GetFingerprint(OBBase* pOb, vector<unsigned int>&fp, int nbits) { OBMol* pmol = dynamic_cast<OBMol*>(pOb); if(!pmol) return false; fp.resize(1024/Getbitsperint()); fragset.clear();//needed because now only one instance of fp class ringset.clear(); //identify fragments starting at every atom OBAtom *patom; vector<OBNodeBase*>::iterator i; for (patom = pmol->BeginAtom(i);patom;patom = pmol->NextAtom(i)) { if(patom->GetAtomicNum() == OBElements::Hydrogen) continue; vector<int> curfrag; vector<int> levels(pmol->NumAtoms()); getFragments(levels, curfrag, 1, patom, NULL); } // TRACE("%s %d frags before; ",pmol->GetTitle(),fragset.size()); //Ensure that each chemically identical fragment is present only in a single DoRings(); DoReverses(); SetItr itr; _ss.str(""); for(itr=fragset.begin();itr!=fragset.end();++itr) { //Use hash of fragment to set a bit in the fingerprint int hash = CalcHash(*itr); SetBit(fp,hash); if(!(Flags() & FPT_NOINFO)) PrintFpt(*itr,hash); } if(nbits) Fold(fp, nbits); // TRACE("%d after\n",fragset.size()); return true; }
Node* CircleModule::evaluate(Context* ctx) { NumberValue* rValue=dynamic_cast<NumberValue*>(getParameterArgument(ctx,0)); double r=1; if(rValue) { r=rValue->getNumber(); } int f = getFragments(r,ctx); Polygon c = getCircle(r,f,0); PrimitiveNode* p = new PrimitiveNode(); if(r > 0) { p->createPolygon(); for(int i=0; i<f; i++) p->appendVertex(c.at(i)); } return p; }
Node* SphereModule::evaluate(Context* ctx) { NumberValue* rValue=dynamic_cast<NumberValue*>(getParameterArgument(ctx,0)); Value* centerValue=getParameterArgument(ctx,1); bool center=true; if(centerValue) center=centerValue->isTrue(); double r=1.0; if(rValue) { r=rValue->getNumber(); } else { NumberValue* dValue = dynamic_cast<NumberValue*>(ctx->getArgument(0,"diameter")); if(dValue) r=(dValue->getNumber()/2.0); } int f = getFragments(r,ctx); int ringCount=f/2; QList<Polygon> rings; for(int i=0; i<ringCount; i++) { double phi = (M_PI*(i+0.5)) / ringCount; double r2 = r*sin(phi); double z = r*cos(phi)+!center*r; Polygon c = getCircle(r2,f,z); rings.append(c); } PrimitiveNode* p = new PrimitiveNode(); p->createPolygon(); for(int i=0; i<f; i++) p->appendVertex(rings.at(0).at(i)); for(int i = 0; i < ringCount-1; i++) { Polygon r1 = rings.at(i); Polygon r2 = rings.at(i+1); int r1i = 0, r2i = 0; while(r1i < f || r2i < f) { if(r1i >= f) goto next_r2; if(r2i >= f) goto next_r1; if((double)r1i / f < (double)r2i / f) { next_r1: p->createPolygon(); int r1j = (r1i+1) % f; p->prependVertex(r1.at(r1i)); p->prependVertex(r1.at(r1j)); p->prependVertex(r2.at(r2i % f)); r1i++; } else { next_r2: p->createPolygon(); int r2j = (r2i+1) % f; p->appendVertex(r2.at(r2i)); p->appendVertex(r2.at(r2j)); p->appendVertex(r1.at(r1i % f)); r2i++; } } } p->createPolygon(); for(int i=0; i<f; i++) p->prependVertex(rings.at(ringCount-1).at(i)); return p; }