1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113
|
// $Id: main.cpp 1625 2011-01-13 04:22:56Z glandrum $
//
// Copyright (C) 2001-2006 Randal Henne, Greg Landrum and Rational Discovery LLC
//
// @@ All Rights Reserved @@
// This file is part of the RDKit.
// The contents are covered by the terms of the BSD license
// which is included in the file license.txt, found at the root
// of the RDKit source tree.
//
#include <iostream>
#include <RDGeneral/RDLog.h>
//#include <boost/log/functions.hpp>
#include "SmilesParse.h"
#include "SmilesWrite.h"
using namespace RDKit;
using namespace std;
typedef ROMol Mol;
int
main(int argc, char *argv[])
{
RDLog::InitLogs();
boost::logging::enable_logs("rdApp.debug");
int i=0;
Mol *mol;
if(argc < 2){
string smis[]={
"C",
"CC",
"C-C",
"C=C",
"[CH2+]C[CH+2]",
"C1CC=1",
"C=1CC1",
"CCC",
"C=C-O",
"C1CC1",
"C1NC1",
"C1=CC1",
"C1CCC1",
"CC(C)CC",
"CC(=O)O",
"C1C(=O)C1",
"C1C(N)C1",
"CC(O)C",
//"(OC)CCC",
"CC=(CO)C",
//"(OC)=CCC",
"OC=CCC",
"CC([O-])O",
"C1CC2C1CC2",
"Cl/C=C/Cl",
"Cl/C=C\\Cl",
"CCC=",
"Cl/C=C/Cl",
"Cl/C=C\\Cl",
"EOS"};
while( smis[i] != "EOS" ){
std::cout << "Doing: " << smis[i] << std::endl;
mol = SmilesToMol(smis[i]);
if (mol) {
std::cout << "\t" << mol->getNumAtoms() << " atoms" << std::endl;
//mol->debugMol(cout);
//std::cout << std::endl;
std::cout << "\tSMILES: ";
std::cout << MolToSmiles(*mol) << std::endl;
delete mol;
}
i++;
}
} else {
string smi;
std::cout << "Doing: " << smi << std::endl;
bool debugParse = false,doSmarts=false;
int startP=1;
while(startP<argc){
string arg(argv[startP]);
if(arg=="-d"){
debugParse = true;
startP++;
}else if(arg=="-sma"){
doSmarts = true;
startP++;
} else {
break;
}
}
while(startP<argc){
smi = argv[startP++];
if(doSmarts){
std::cout << "In SMARTS: " << smi << std::endl;
mol = SmartsToMol(smi,debugParse);
} else {
std::cout << "In SMILES: " << smi << std::endl;
mol = SmilesToMol(smi,debugParse);
std::cout << "Out SMILES: " << std::endl;
smi = MolToSmiles(*mol,true);
std::cout << " " << smi << std::endl;
}
}
}
return 1;
}
|