| 1 | /********************************************************************** | 
| 2 | Copyright (C) 1998-2001 by OpenEye Scientific Software, Inc. | 
| 3 | Some portions Copyright (C) 2001-2005 by Geoffrey R. Hutchison | 
| 4 | Some portions Copyright (C) 2004 by Chris Morley | 
| 5 |  | 
| 6 | This program is free software; you can redistribute it and/or modify | 
| 7 | it under the terms of the GNU General Public License as published by | 
| 8 | the Free Software Foundation version 2 of the License. | 
| 9 |  | 
| 10 | This program is distributed in the hope that it will be useful, | 
| 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 
| 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
| 13 | GNU General Public License for more details. | 
| 14 | ***********************************************************************/ | 
| 15 | //Contains SMIFormat and FIXFormat classes | 
| 16 |  | 
| 17 | #ifndef OB_SMILESFORMAT_HPP | 
| 18 | #define OB_SMILESFORMAT_HPP | 
| 19 |  | 
| 20 | #include "mol.hpp" | 
| 21 | #include "obconversion.hpp" | 
| 22 | #include "obmolecformat.hpp" | 
| 23 |  | 
| 24 | using namespace std; | 
| 25 |  | 
| 26 | namespace OpenBabel | 
| 27 | { | 
| 28 | class SMIFormat : public OBMoleculeFormat | 
| 29 | { | 
| 30 | public: | 
| 31 | //Register this format type ID | 
| 32 | SMIFormat() | 
| 33 | { | 
| 34 | OBConversion::RegisterFormat("smi",this, "chemical/x-daylight-smiles"); | 
| 35 | OBConversion::RegisterOptionParam("n", this); | 
| 36 | OBConversion::RegisterOptionParam("t", this); | 
| 37 | } | 
| 38 |  | 
| 39 | virtual const char* GetMIMEType() | 
| 40 | { return "chemical/x-daylight-smiles"; }; | 
| 41 |  | 
| 42 | //////////////////////////////////////////////////// | 
| 43 | /// The "API" interface functions | 
| 44 | virtual bool ReadMolecule(OBBase* pOb, OBConversion* pConv); | 
| 45 | virtual bool WriteMolecule(OBBase* pOb, OBConversion* pConv); | 
| 46 |  | 
| 47 | /////////////////////////////////////////////////////// | 
| 48 |  | 
| 49 | virtual const char* Description() | 
| 50 | { | 
| 51 | return | 
| 52 | "SMILES format\n \ | 
| 53 | A linear text format which can describe the connectivity\n \ | 
| 54 | and chirality of a molecule\n \ | 
| 55 | Write Options e.g. -xt\n \ | 
| 56 | -n no molecule name\n \ | 
| 57 | -t molecule name only\n \ | 
| 58 | -r radicals lower case eg ethyl is Cc\n\n"; | 
| 59 | }; | 
| 60 |  | 
| 61 | virtual const char* SpecificationURL() | 
| 62 | {return "http://www.daylight.com/dayhtml/smiles/";}; //optional | 
| 63 |  | 
| 64 | virtual int SkipObjects(int n, OBConversion* pConv) | 
| 65 | { | 
| 66 | if(n==0) return 1; //already points after current line | 
| 67 | string temp; | 
| 68 | istream& ifs = *pConv->GetInStream(); | 
| 69 | int i; | 
| 70 | for(i=0;i<n && ifs.good();i++) | 
| 71 | getline(ifs, temp); | 
| 72 | return ifs.good() ? 1 : -1; | 
| 73 | }; | 
| 74 | }; | 
| 75 |  | 
| 76 | } | 
| 77 |  | 
| 78 | #endif |