Created
December 16, 2008 08:17
-
-
Save mesprague/36376 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Text; | |
using System.Collections.Generic; | |
using System.Linq; | |
using OpenBabel; | |
namespace OBDotNetExamples | |
{ | |
class Program1 | |
{ | |
static void Main(string[] args) | |
{ | |
//Set up a translator to Sybyl atom types | |
OBTypeTable ttab = new OBTypeTable(); | |
ttab.SetFromType("INT"); | |
ttab.SetToType("SYB"); | |
OBConversion obc = new OBConversion(); | |
obc.SetInFormat("smi"); | |
OBMol mol = new OBMol(); | |
obc.ReadString(mol, "c1(N)ccccc1c(=O)[O-]"); | |
int maxDepth = 3; | |
string atomType; | |
List<string> fp = new List<string>(); | |
List<string> fpBlock; | |
for(int i = 1; i <= mol.NumAtoms(); i++) | |
{ | |
fpBlock = new List<string>(); | |
foreach(var pair in mol.AtomsBFSWDepth(i)) | |
{ | |
if(pair.Depth > maxDepth) | |
break; | |
atomType = ttab.Translate(pair.Atom.GetAtomType()); | |
fpBlock.Add(string.Format("{0}-{1}",pair.Depth-1,atomType)); | |
} | |
fpBlock.Sort(); | |
fp.Add(string.Join(";", fpBlock.ToArray())); | |
} | |
Console.WriteLine(string.Join("\t", fp.ToArray())); | |
} | |
/* output: | |
0-C.ar;1-C.ar;1-C.ar;1-N.pl3;2-C.2;2-C.ar;2-C.ar 0-N.pl3;1-C.ar;2-C.ar;2-C.ar 0- | |
C.ar;1-C.ar;1-C.ar;2-C.ar;2-C.ar;2-N.pl3 0-C.ar;1-C.ar;1-C.ar;2-C.ar;2-C.ar 0- | |
C.ar;1-C.ar;1-C.ar;2-C.ar;2-C.ar 0-C.ar;1-C.ar;1-C.ar;2-C.2;2-C.ar;2-C.ar 0- | |
C.ar;1-C.2;1-C.ar;1-C.ar;2-C.ar;2-C.ar;2-N.pl3;2-O.co2;2-O.co2 0-C.2;1-C.ar;1-O.co2;1-O.c | |
o2;2-C.ar;2-C.ar 0-O.co2;1-C.2;2-C.ar;2-O.co2 0-O.co2;1-C.2;2-C.ar;2-O.co2 | |
*/ | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment