当前位置: 首页>>代码示例>>C++>>正文


C++ OBMol::GetTitle方法代码示例

本文整理汇总了C++中OBMol::GetTitle方法的典型用法代码示例。如果您正苦于以下问题:C++ OBMol::GetTitle方法的具体用法?C++ OBMol::GetTitle怎么用?C++ OBMol::GetTitle使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在OBMol的用法示例。


在下文中一共展示了OBMol::GetTitle方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: WriteViewMol

bool WriteViewMol(ostream &ofs,OBMol &mol)
{
  unsigned int i;
  char buffer[BUFF_SIZE];
  
  if (strlen(mol.GetTitle()) > 0)
    ofs << "$title" << endl << mol.GetTitle() << endl;

  ofs << "$coord 1.0" << endl;

  OBAtom *atom;
  for(i = 1;i <= mol.NumAtoms(); i++)
  {
    atom = mol.GetAtom(i);
    sprintf(buffer,"%22.14f%22.14f%22.14f %s",
	    atom->GetX(),
	    atom->GetY(),
	    atom->GetZ(),
	    etab.GetSymbol(atom->GetAtomicNum()));
    ofs << buffer << endl;
  }

  ofs << "$end" << endl;

  return(true);

}
开发者ID:daju1,项目名称:winlibghemical,代码行数:27,代码来源:viewmol.cpp

示例2: aromatic_test

void aromatic_test()
{
  cout << endl << "# Testing aromaticity perception...  " << endl;

  string filename = "files/aromatics.smi";
  
  ifstream ifs(filename.c_str());
  BOOST_REQUIRE_MESSAGE( ifs, "Bail out! Cannot read input file!" );
  
  OBConversion conv(&ifs, &cout);
  OBFormat* pFormat;
  
  pFormat = conv.FormatFromExt(filename.c_str());
  BOOST_REQUIRE_MESSAGE( pFormat != NULL, "Bail out! Cannot read file format!" );
  
  // Finally, we can do some work!
  OBMol mol;
  
  unsigned int testCount = 0;

  BOOST_REQUIRE_MESSAGE( conv.SetInAndOutFormats(pFormat, pFormat), "Bail out! File format isn't loaded");
  
  int molCount = 0;
  char message[BUFF_SIZE];
  while(ifs.peek() != EOF && ifs.good())
    {
      mol.Clear();
      conv.Read(&mol);
      molCount++;
      
      FOR_ATOMS_OF_MOL(atom, mol)
        {
          if (atom->IsHydrogen())
            continue;

          testCount++;
          
	  snprintf(message, BUFF_SIZE, "not ok %d # atom isn't aromatic!\n"
		      "# atom idx %d in molecule %d %s", 
		      testCount, atom->GetIdx(), molCount, mol.GetTitle());
          BOOST_CHECK_MESSAGE( atom->IsAromatic(), message );
        }

      FOR_BONDS_OF_MOL(bond, mol)
        {
          if (!bond->IsInRing())
            continue;
          
	  testCount++;
        
	  snprintf(message, BUFF_SIZE, "not ok %d # bond isn't aromatic!\n"
                                       "# begin atom %d, end atom %d, bond order %d in molecule %d %s", 
                                       testCount, bond->GetBeginAtomIdx(), bond->GetEndAtomIdx(),
				       bond->GetBondOrder(), molCount, mol.GetTitle());
          BOOST_CHECK_MESSAGE( bond->IsAromatic(), message );
        }
	
    } // while reading molecules
    
}
开发者ID:arebzanipro,项目名称:contributed,代码行数:60,代码来源:aromatest.cpp

示例3: Do

bool OpUnique::Do(OBBase* pOb, const char* OptionText, OpMap* pmap, OBConversion* pConv)
{
  OBMol* pmol = dynamic_cast<OBMol*>(pOb);
  if(!pmol)
    return false;

  if(pConv->IsFirstInput())
  {
    _ndups=0;
    string descID("inchi"); // the default
    _trunc.clear();
    _inv = OptionText[0]=='~';   //has the parameter a leading ~ ?
    if(_inv)
      clog << "The output has the duplicate structures" << endl;

    if(OptionText[0+_inv]=='/')  //is parameter is /x?
      _trunc = OptionText+_inv;
    else if(OptionText[0+_inv]!='\0') // not empty?
      descID = OptionText+_inv;

    _pDesc = OBDescriptor::FindType(descID.c_str());
    if(!_pDesc)
    {
      obErrorLog.ThrowError(__FUNCTION__,
              "Cannot find descriptor " + descID, obError, onceOnly);
      return false;
    }
    _pDesc->Init();
    _inchimap.clear();

    _reportDup = !_inv; //do not report duplicates when they are the output
  }

  if(!_pDesc)
    return false;
  std::string s;
  _pDesc->GetStringValue(pmol, s);

  if(!_trunc.empty())
    InChIFormat::EditInchi(s, _trunc);
  std::pair<UMap::iterator, bool> result = _inchimap.insert(make_pair(s, pmol->GetTitle()));
  bool ret = true;
  if(!s.empty() && !result.second)
  {
    // InChI is already present in set
    ++_ndups;
    if(_reportDup)
      clog << "Removed " << pmol->GetTitle() << " - a duplicate of " << result.first->second
         << " (#" << _ndups << ")" << endl;
    //delete pOb;
    ret = false; //filtered out
  }
  if(_inv)
    ret = !ret;
  if(!ret)
    delete pOb;
  return ret;
}
开发者ID:Acpharis,项目名称:openbabel,代码行数:58,代码来源:unique.cpp

示例4: WriteXYZ

bool WriteXYZ(ostream &ofs,OBMol &mol)
{
  unsigned int i;
  char buffer[BUFF_SIZE];
  
  sprintf(buffer,"%d", mol.NumAtoms());
  ofs << buffer << endl;
  sprintf(buffer,"%s\tEnergy: %15.7f", mol.GetTitle(), mol.GetEnergy());
  ofs << buffer << endl;

  OBAtom *atom;
  string str,str1;
  for(i = 1;i <= mol.NumAtoms(); i++)
  {
    atom = mol.GetAtom(i);
    sprintf(buffer,"%3s%15.5f%15.5f%15.5f",
	    etab.GetSymbol(atom->GetAtomicNum()),
	    atom->GetX(),
	    atom->GetY(),
	    atom->GetZ());
    ofs << buffer << endl;
  }

  return(true);
}
开发者ID:daju1,项目名称:winlibghemical,代码行数:25,代码来源:xyz.cpp

示例5: WriteMolecule

bool XXXFormat::WriteMolecule(OBBase* pOb, OBConversion* pConv)
{
  OBMol* pmol = dynamic_cast<OBMol*>(pOb);
  if(pmol==NULL)
      return false;

  ostream& ofs = *pConv->GetOutStream();

	/** Write the representation of the OBMol molecule to the output stream **/

	//To use an output option
	if(!pConv->IsOption("n")) //OBConversion::OUTOPTIONS is the default
		ofs << "Title = " << pmol->GetTitle() << endl;
	//or if the option has a parameter
	int levels=0;
	const char* p = pConv->IsOption("f");
	if(p) //p==NULL if f option absent
		levels = atoi(p);

	// To find out whether this is the first molecule to be output...
	if(pConv->GetOutputIndex()==1)
		ofs << "The contents of this file were derived from " << pConv->GetInFilename() << endl;
	// ... or the last
	if(!pConv->IsLast())
		ofs << "$$$$" << endl;

	return true; //or false to stop converting
}
开发者ID:Acpharis,项目名称:openbabel,代码行数:28,代码来源:exampleformat.cpp

示例6: GetStringValue

double TitleFilter::GetStringValue(OBBase *pOb, std::string &svalue,
                                   std::string *) {
  OBMol *pmol = dynamic_cast<OBMol *>(pOb);
  if (pmol)
    svalue = pmol->GetTitle();
  return std::numeric_limits<double>::quiet_NaN();
}
开发者ID:Reinis,项目名称:openbabel,代码行数:7,代码来源:filters.cpp

示例7: WriteCSRHeader

void CSRFormat::WriteCSRHeader(ostream &ofs,OBMol &mol)
{
    char *molnames;
    int nmol, natom;

    molnames = PadString((char*)mol.GetTitle(),100);

    nmol = 1;
    natom = mol.NumAtoms();

    WriteSize(4*sizeof(char),ofs);
    ofs.write("V33 ",strlen("V33 ")*sizeof(char));
    WriteSize(4*sizeof(char),ofs);

    WriteSize(2*sizeof(int),ofs);
    ofs.write((char*)&natom,sizeof(int));
    ofs.write((char*)&nmol,sizeof(int));
    WriteSize(2*sizeof(int),ofs);

    WriteSize(100*sizeof(char),ofs);
    ofs.write(molnames,100*sizeof(char));
    WriteSize(100*sizeof(char),ofs);

    WriteSize(sizeof(int),ofs);
    ofs.write((char*)&natom,sizeof(int));
    WriteSize(sizeof(int),ofs);

    delete [] molnames;
}
开发者ID:CooperLiu,项目名称:openbabel,代码行数:29,代码来源:CSRformat.cpp

示例8: ReadMolecule

  bool GenBankFormat::ReadMolecule(OBBase* pOb, OBConversion* pConv)
  {
    OBMol* pmol = pOb->CastAndClear<OBMol>();
    if (pmol == 0)
      return false;


    std::istream * in = pConv->GetInStream();
    pmol->BeginModify();

    std::string line;

    SequenceType sequence_type = UnknownSequence;
    getline( * in, line);
    while (!in->eof())
      { // We have a new line in 'line'
      if (!line.compare(0, 6, "LOCUS", 6) || !line.compare(0, 2, "ID ", 2))
        {
        if (sequence_type == GenBankFormat::UnknownSequence)
          { // attempt to determine the sequence type
          if (line.find("RNA") != std::string::npos)
            sequence_type = GenBankFormat::RNASequence;
          else if (line.find("DNA") != std::string::npos)
            sequence_type = GenBankFormat::DNASequence;
          }
        }
      else if (!line.compare(0, 6, "DEFINITION", 6) || !line.compare(0, 2, "DE ", 2))
        {
        if (sequence_type == GenBankFormat::UnknownSequence)
          { // attempt to determine the sequence type
          if (line.find("RNA") != std::string::npos)
            sequence_type = GenBankFormat::RNASequence;
          else if (line.find("DNA") != std::string::npos)
            sequence_type = GenBankFormat::DNASequence;
          else if (line.find("gene") != std::string::npos)
            sequence_type = GenBankFormat::DNASequence;
          }
        if (pmol->GetTitle()[0] == 0)
          {
          std::string::size_type fc = line.find(' ');
          while (fc != std::string::npos && strchr(" \t\n\r", line[fc]))
            ++ fc;
          if (fc != std::string::npos)
            pmol->SetTitle( & (line.c_str()[fc]) );
          }
        }
      else if (!line.compare(0, 6, "ORIGIN", 6) || !line.compare(0, 2, "SQ ", 2))
        break;

      getline( * in, line);
      }
    if (sequence_type == GenBankFormat::UnknownSequence)
      sequence_type = GenBankFormat::DNASequence;

    bool rv = ReadFASTASequence(pmol, sequence_type, in,
        !pConv->IsOption("b",OBConversion::INOPTIONS), !pConv->IsOption("s",OBConversion::INOPTIONS));
	  pmol->EndModify();
    return rv;
  }
开发者ID:Antipina,项目名称:OpenBabel-BFGS,代码行数:59,代码来源:genbankformat.cpp

示例9: WriteMolecule

bool ThermoFormat::WriteMolecule(OBBase* pOb, OBConversion* pConv)
{
  OBMol* pmol = dynamic_cast<OBMol*>(pOb);
  string title(pmol->GetTitle());
  OBNasaThermoData* pND = static_cast<OBNasaThermoData*>(pmol->GetData(ThermoData));
  if(!pND)
  {
    obErrorLog.ThrowError(__FUNCTION__,"No thermo data in " + title, obWarning);
    return false;
  }
  ostream &ofs = *pConv->GetOutStream();
  unsigned int i;
#ifdef _MSC_VER
  unsigned oldf = _set_output_format(_TWO_DIGIT_EXPONENT);
#endif
  string formula = pmol->GetSpacedFormula();
  vector<string> toks;
  tokenize(toks,formula);

  ofs << left << setw(24) << title.substr(0,24);
  //Check that atom numbers are less than 999
  bool toobig=toks.size()>8;
  for(i=0;i<toks.size() && !toobig ;i+=2)
    if(atoi(toks[i+1].c_str())>999)
      toobig =true;
  if(toobig)
    //Reaction Design extension
    ofs << string(20,' ');
  else
  {
    toks.resize(8);
    for(i=0;i<8;i+=2)
    ofs << left << setw(2) << toks[i] << right << setw(3) << toks[i+1];
  }
  ofs << right << pND->GetPhase() << fixed << setprecision(3) << setw(10) << pND->GetLoT();
  ofs << setw(10) << pND->GetHiT() << setw(9) << pND->GetMidT() << "    01";

  if(toobig)
    ofs << "&\n" << formula << '\n';
  else
    ofs << '\n';

  ofs << scientific << setprecision(7);
  for(i=0;i<5;++i)
    ofs << setw(15) << pND->GetCoeff(i);
  ofs << "    2\n";
  for(i=5;i<10;++i)
    ofs << setw(15) << pND->GetCoeff(i);
  ofs << "    3\n";
  for(i=10;i<14;++i)
    ofs << setw(15) << pND->GetCoeff(i);
  ofs << "                   4\n";

#ifdef _MSC_VER
  _set_output_format(oldf);
#endif

  return true;
}
开发者ID:baoilleach,项目名称:openbabel-svn-mirror,代码行数:59,代码来源:thermoformat.cpp

示例10: WriteChemObjectImpl

bool OBMoleculeFormat::WriteChemObjectImpl(OBConversion* pConv, OBFormat* pFormat)
{
    if(pConv->IsOption("C",OBConversion::GENOPTIONS))
        return OutputDeferredMols(pConv);
    if(pConv->IsOption("j",OBConversion::GENOPTIONS)
            || pConv->IsOption("join",OBConversion::GENOPTIONS))
    {
        //arrives here at the end of a file
        if(!pConv->IsLast())
            return true;
        bool ret=pFormat->WriteMolecule(_jmol,pConv);
        pConv->SetOutputIndex(1);
        delete _jmol;
        return ret;
    }


    //Retrieve the target OBMol
    OBBase* pOb = pConv->GetChemObject();

    OBMol* pmol = dynamic_cast<OBMol*> (pOb);
    bool ret=false;
    if(pmol)
    {
        if(pmol->NumAtoms()==0)
        {
            std::string auditMsg = "OpenBabel::Molecule ";
            auditMsg += pmol->GetTitle();
            auditMsg += " has 0 atoms";
            obErrorLog.ThrowError(__FUNCTION__,
                                  auditMsg,
                                  obInfo);
        }
        ret=true;

        std::string auditMsg = "OpenBabel::Write molecule ";
        std::string description(pFormat->Description());
        auditMsg += description.substr(0,description.find('\n'));
        obErrorLog.ThrowError(__FUNCTION__,
                              auditMsg,
                              obAuditMsg);

        ret = DoOutputOptions(pOb, pConv);

        if(ret)
            ret = pFormat->WriteMolecule(pmol,pConv);
    }

#ifdef HAVE_SHARED_POINTER
    //If sent a OBReaction* (rather than a OBMol*) output the consituent molecules
    OBReaction* pReact = dynamic_cast<OBReaction*> (pOb);
    if(pReact)
        ret = OutputMolsFromReaction(pReact, pConv, pFormat);
#endif
    delete pOb;
    return ret;
}
开发者ID:sneumann,项目名称:pgchem,代码行数:57,代码来源:obmolecformat.cpp

示例11: Compare

bool TitleFilter::Compare(OBBase *pOb, istream &optionText, bool noEval,
                          std::string *) {
  OBMol *pmol = dynamic_cast<OBMol *>(pOb);
  if (!pmol)
    return false;

  string title(pmol->GetTitle());
  return CompareStringWithFilter(optionText, title, noEval);
}
开发者ID:Reinis,项目名称:openbabel,代码行数:9,代码来源:filters.cpp

示例12: WriteMolecule

bool TitleFormat::WriteMolecule(OBBase* pOb, OBConversion* pConv)
{
  OBMol* pmol = dynamic_cast<OBMol*>(pOb);
  if(pmol==NULL)
      return false;

  ostream &ofs = *pConv->GetOutStream();
	ofs << pmol->GetTitle() << endl;
	return true;
}
开发者ID:candycode,项目名称:openbabel,代码行数:10,代码来源:titleformat.cpp

示例13: snprintf

  bool CHEM3D1Format::WriteChem3d(ostream &ofs,OBMol &mol, const char *mol_typ)
  {
    int atnum;
    int type_num;
    char buffer[BUFF_SIZE],type_name[16],ele_type[16];

    ofs << mol.NumAtoms();
    if (EQ(mol_typ,"MMADS"))
      {
        ofs << " " << mol.GetTitle();
        ttab.SetToType("MM2");
      }
    else
      ttab.SetToType(mol_typ);
    ofs << endl;

    ttab.SetFromType("INT");

    OBAtom *atom,*nbr;
    vector<OBAtom*>::iterator i;
    vector<OBBond*>::iterator j;

    for (atom = mol.BeginAtom(i);atom;atom = mol.NextAtom(i))
      {
        if (!ttab.Translate(type_name,atom->GetType()))
          {
            snprintf(buffer, BUFF_SIZE,
                     "Unable to assign %s type to atom %d type = %s\n",
                     mol_typ,atom->GetIdx(),atom->GetType());
            obErrorLog.ThrowError(__FUNCTION__, buffer, obInfo);
            atnum = atom->GetAtomicNum();
            type_num = atnum * 10 + atom->GetValence();
            snprintf(type_name, sizeof(type_num), "%d",type_num);
          }
        strncpy(ele_type, etab.GetSymbol(atom->GetAtomicNum()), sizeof(ele_type));
        ele_type[sizeof(ele_type) - 1] = '\0';
        snprintf(buffer, BUFF_SIZE, "%-3s %-5d %8.4f  %8.4f  %8.4f %5s",
                ele_type,
                atom->GetIdx(),
                atom->x(),
                atom->y(),
                atom->z(),
                type_name);
        ofs << buffer;

        for (nbr = atom->BeginNbrAtom(j);nbr;nbr = atom->NextNbrAtom(j))
          {
            snprintf(buffer, BUFF_SIZE, "%6d",nbr->GetIdx());
            ofs << buffer;
          }
        ofs << endl;
      }
    return(true);
  }
开发者ID:Acpharis,项目名称:openbabel,代码行数:54,代码来源:chem3dformat.cpp

示例14: WriteGromos96

bool WriteGromos96(ostream &ofs,OBMol &mol,double fac)
{ 
  char type_name[10];
  char res_name[10],padded_name[10];
  char buffer[BUFF_SIZE];
  int res_num;

  sprintf(buffer,"#GENERATED BY OPEN BABEL %s",BABEL_VERSION);
  ofs << buffer << endl;

  /* GROMOS wants a TITLE block, so let's write one*/
  sprintf(buffer,"TITLE\n%s\nEND",mol.GetTitle());
  ofs << buffer << endl;
  ofs << "POSITION" << endl;

  OBAtom *atom;
  OBResidue *res;
  vector<OBNodeBase*>::iterator i;

  for(atom = mol.BeginAtom(i);atom;atom = mol.NextAtom(i))
    {
      if (res = atom->GetResidue())
	{
	  strcpy(res_name,(char*)res->GetName().c_str());
	  strcpy(type_name,(char*)res->GetAtomID(atom).c_str());
	  res_num = res->GetNum();
	}
      else
	{
	  strcpy(type_name,etab.GetSymbol(atom->GetAtomicNum()));
	  strcpy(res_name,"UNK");
	  sprintf(padded_name,"%2s",type_name);
	  strcpy(type_name,padded_name);
	  res_num = 1;
	}
      
      sprintf(buffer,"%5d %5s %5s %6d %15.5f %15.5f %15.5f",
	      res_num,res_name,type_name,atom->GetIdx(),
	      atom->x()*fac,atom->y()*fac,atom->z()*fac);
      ofs << buffer << endl;

      if (!(atom->GetIdx()%10))
      {
	sprintf(buffer,"# %d",atom->GetIdx());
	ofs << buffer << endl;
      }
    }

  ofs << "END" << endl;

  return(true);
}
开发者ID:daju1,项目名称:winlibghemical,代码行数:52,代码来源:gromos96.cpp

示例15: GenerateEnergies

void GenerateEnergies()
{
  std::ifstream ifs;
  if (!SafeOpen(ifs, molecules_file.c_str()))
    return;

  std::ofstream ofs;
  if (!SafeOpen(ofs, results_file.c_str()))
    return;

  OBMol mol;
  OBConversion conv(&ifs, &cout);
  char buffer[BUFF_SIZE];
  
  if(! conv.SetInAndOutFormats("SDF","SDF"))
    {
      cerr << "SDF format is not loaded" << endl;
      return;
    }

  OBForceField* pFF = OBForceField::FindForceField("Ghemical");

  if (pFF == NULL) {
    cerr << "Cannot load force field!" << endl;
    return;
  }

  pFF->SetLogFile(&cout);
  pFF->SetLogLevel(OBFF_LOGLVL_NONE);

  for (;ifs;)
    {
      mol.Clear();
      conv.Read(&mol);
      if (mol.Empty())
        continue;

      if (!pFF->Setup(mol)) {
        cerr << "Could not setup force field on molecule: " << mol.GetTitle() << endl;
        return;
      }
      
      // Don't compute gradients
      sprintf(buffer, "%15.5f\n", pFF->Energy(false));
      ofs << buffer;
    }

	cerr << " Ghemical force field energies written successfully" << endl;
  return;
}
开发者ID:annulen,项目名称:openbabel,代码行数:50,代码来源:ffghemical.cpp


注:本文中的OBMol::GetTitle方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。