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


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

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


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

示例1: main


//.........这里部分代码省略.........
				{
					resolution = atof(optarg);
					if (resolution <= 0)
					{
						msg = "Resolution -r should be larger than 0.0: ";
						msg += optarg;
						showError(msg);
						exit(1);
					}
				}
				break;
				
			case 'h':
				showHelp(argv[0]);
				exit(0);
				break;
				
			case '?':
				if ((optopt == 'i') || 
						(optopt == 'n') || 
						(optopt == 'a') || 
						(optopt == 's') || 
						(optopt == 'r'))
				{
					msg = "Option -";
					msg += optopt;
					msg += " requires an argument.";
					showError(msg);
					exit(1);
				}
				else
				{
					msg = "Unknown option -";
					msg += optopt;
					msg += ".";
					showError(msg);
					exit(1);
				}
				break;
				
			default:
				showError("Unknown option");
				exit(1);
				break;
		}
	}
	
	// The input file (-i) is the only required option
	if (ifile.empty())
	{
		msg = "Input file specification is required (option -i).";
		showError(msg);
		exit(1);
	}
	OpenBabel::OBConversion obconversion;
	OpenBabel::OBFormat *format = obconversion.FormatFromExt(ifile.c_str());
	if (!format)
	{
		msg = "Could not find file format for ";
		msg += ifile;
		showError(msg);
		exit(1);
	}
	obconversion.SetInFormat(format);
	std::ifstream ifs;
	ifs.open(ifile.c_str());
	obconversion.SetInStream(&ifs);
	
	// Start calculations
	OpenBabel::OBMol mol;
	OpenBabel::OBSpectrophore spec;
	spec.SetAccuracy(accuracy);
	spec.SetNormalization(normalization);
	spec.SetStereo(stereo);
	spec.SetResolution(resolution);
	showParameters(spec, ifile);
	unsigned int count(0);
	while (obconversion.Read(&mol))
	{
		std::vector<double> result = spec.GetSpectrophore(&mol);
		if (result.empty()) {
			std::cerr << "Error calculating Spectrophore from molecule number ";
			std::cerr << count;
			std::cerr << " (counting starts at 0)!";
			std::cerr << std::endl;
		}
		else
		{
			std::cout << mol.GetTitle() << "\t";
			for (unsigned int i(0); i < result.size(); ++i)
			{
				std::cout << result[i] << "\t";
			}
			std::cout << std::endl;
		}
		mol.Clear();
		++count;
	}
	return 0;
}
开发者ID:Antipina,项目名称:OpenBabel-BFGS,代码行数:101,代码来源:obspectrophore.cpp

示例2: main


//.........这里部分代码省略.........
      {
         uo.dbInpType = MOL;
      }
   }
	
	// local storage of the rotation matrix
	SiMath::Matrix rotMat(3,3,0.0);

   unsigned int molCount(0);
   
   OpenBabel::OBConversion* molReader = NULL;
	PharmacophoreReader* pharmReader = NULL;
   
   if (uo.dbInpType == PHAR)
   {
      pharmReader = new PharmacophoreReader();
   }
   else if (uo.dbInpType == MOL)
   {
      molReader = new OpenBabel::OBConversion();
      molReader->SetInFormat(molReader->FormatFromExt(uo.dbInpFile.c_str()));
      molReader->SetInStream(uo.dbInpStream);
   }
   else
   {
      mainErr("Unknown format of db file.");
   }

   bool done(false);
   OpenBabel::OBMol m;
   while (!done)
   {	
      dbPharm.clear();
      m.Clear();

      if (uo.dbInpType == MOL)
      {
         if (!molReader->Read(&m))
         {
            done = true;
            break;
         }
         else
         {
            calcPharm(&m, &dbPharm, uo);
            dbId = m.GetTitle();
         }
      }
      else
      {
         if (uo.dbInpStream->eof())
         {
            done = true;
            break;
         }
         else
         {
            dbPharm = pharmReader->read(uo.dbInpStream, dbId);
         }
      }
      if (dbPharm.empty())
      {
         continue;
      }

      ++molCount;
开发者ID:UnixJunkie,项目名称:pharao,代码行数:67,代码来源:main.cpp

示例3:


//.........这里部分代码省略.........
   	{
      	*(o->OutStream()) << "NAME\tMOLECULE";
   	}
   	for (unsigned int i(0); i < scaffolds.size(); ++i)
   	{
      	s = dynamic_cast<Scaffold*>(scaffolds[i]);
      	if (o->OutFilename().empty())
      	{
        	std::cout << "\t" << s->PrintName();
      	}
      	else
      	{
         	*(o->OutStream()) << "\t" << s->PrintName();
      	}
   	}
   	if (o->OutFilename().empty())
   	{
     	std::cout << std::endl;
   	}
   	else
   	{
      	*(o->OutStream()) << std::endl;
    }
      
   	// Process molecules
   	OpenBabel::OBMol mol;
   	std::string title;
   	OpenBabel::OBConversion mol2can;
   	mol2can.SetOutFormat("can");
   	mol2can.AddOption("n", OpenBabel::OBConversion::OUTOPTIONS);
		
	// first set the stream (needed in case of a zip stream)
    o->InputConverter()->SetInStream(o->InputStream());
   	while (o->InputConverter()->Read(&mol))
   	{
      	// Drop stereo information
      	mol.DeleteData(OpenBabel::OBGenericDataType::StereoData);

      	// Extract a suitable title from molecule
      	counter.NewMolecule();
      	title.clear();
      	title = mol.GetTitle();
      	if (title == "")
      	{
         	mol.SetTitle(mol2can.WriteString(&mol, true).c_str());
      	}
      	if (o->OutFilename().empty())
      	{
         	std::cout << mol.GetTitle();
      	}
      	else
      	{
         	*(o->OutStream()) << mol.GetTitle();
      	}
      	
		// Print smiles
      	if (o->OutFilename().empty())
      	{
         	std::cout << "\t" << mol2can.WriteString(&mol, true);
      	}
      	else
      	{
         	*(o->OutStream()) << "\t" << mol2can.WriteString(&mol, true);
      	}
      
      	// Extract scaffolds
      	for (unsigned int i(0); i < scaffolds.size(); ++i)
      	{
         	s = dynamic_cast<Scaffold*>(scaffolds[i]);
         	if (s->CalculateScaffold(mol, o))
         	{
            	counter.NewScaffold();
         	}
         	else
         	{
            	counter.FailedScaffold();
         	}
         	if (o->OutFilename().empty())
         	{
            	std::cout << "\t" << s->PrintScaffold();
         	}
         	else
         	{
            	*(o->OutStream()) << "\t" << s->PrintScaffold();
         	}
      	}
      	if (o->OutFilename().empty())
      	{
         	std::cout << std::endl;
      	}
      	else
      	{
         	*(o->OutStream()) << std::endl;
      	}
      	mol.Clear();
   	}

   	// Return
   	return counter;
}
开发者ID:UnixJunkie,项目名称:stripper,代码行数:101,代码来源:calculator.cpp


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