C++



Features & Limitations

Download & Installation

Example Code Compilation & Execution

cansmi.c
#include <stdio.h>
#include <string.h>
#include "dt_smiles.h"

int main(int argc, char *argv[])
{
  dt_Handle mol;
  int       lencan;
  char      *cansmi, line[1000];

  while (gets(line)) {
    mol = dt_smilin(strlen(line), line);
    if (mol == NULL_OB)
      fprintf(stderr, "ERROR: Can't parse \"%s\"\n", line);
    else {
      cansmi = dt_cansmiles(&lencan, mol, 0);
      if (cansmi && (lencan > 0))
        printf("%.*s\n", lencan, cansmi);
      else
        fprintf(stderr, "ERROR: Can't make unique SMILES for \"%s\"\n", line);
      dt_dealloc(mol);
    }
  }
  return 0;
}
% gcc -I/usr/local/daylight/v/include -L/usr/local/daylight/v/lib -c cansmi.c
% gcc -o cansmi -I/usr/local/daylight/v/include -L/usr/local/daylight/v/lib cansmi.o -ldt_smiles -lsocket -lnsl -lw -ldl -lintl -lm -lmalloc 
% echo "OCC" | ./cansmi   
CCO    
cansmi.cpp
#include <stdio.h>
#include <string.h>
#include "dt_smiles.h"
#define  _cplusplus

int main(int argc, char *argv[])
{
  dt_Handle mol;
  int       lencan;
  char      *cansmi, line[1000];

  while (gets(line)) {
    mol = dt_smilin(strlen(line), line);
    if (mol == NULL_OB)
      fprintf(stderr, "ERROR: Can't parse \"%s\"\n", line);
    else {
      cansmi = dt_cansmiles(&lencan, mol, 0);
      if (cansmi && (lencan > 0))
        printf("%.*s\n", lencan, cansmi);
      else
        fprintf(stderr, "ERROR: Can't make unique SMILES for \"%s\"\n", line);
      dt_dealloc(mol);
    }
  }
  return 0;
}
% g++ -I/usr/local/daylight/v/include -L/usr/local/daylight/v/lib -c cansmi.cpp
% g++ -o cansmi -I/usr/local/daylight/v/include -L/usr/local/daylight/v/lib  cansmi.o -ldt_smiles -lsocket -lnsl -lw -ldl -lintl -lm -lmalloc
% echo "OCC" | ./cansmi
CCO