InChI
 
Loading...
Searching...
No Matches
mol_fmt2.c File Reference
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include <math.h>
#include <float.h>
#include <limits.h>
#include "mode.h"
#include "mol_fmt.h"
#include "ichierr.h"
#include "util.h"
#include "ichi_io.h"
#include "bcf_s.h"
+ Include dependency graph for mol_fmt2.c:

Macros

#define MIN_STDATA_X_COORD   0.0
 
#define MAX_STDATA_X_COORD   256.0
 
#define MIN_STDATA_Y_COORD   0.0
 
#define MAX_STDATA_Y_COORD   256.0
 
#define MIN_STDATA_Z_COORD   0.0
 
#define MAX_STDATA_Z_COORD   256.0
 
#define MAX_STDATA_AVE_BOND_LENGTH   20.0
 
#define MIN_STDATA_AVE_BOND_LENGTH   10.0
 

Functions

int MolfileStrnread (char *dest, char *source, int len, char **first_space)
 Read a string from a source buffer into a destination buffer.
 
int MolfileReadField (void *data, int field_len, int data_type, char **line_ptr)
 Extract the 'data' in the MOL file field at given text position 'line_ptr'.
 
long MolfileExtractStrucNum (MOL_FMT_HEADER_BLOCK *pHdr)
 Extract the MOL file number from the header name line like "Structure #22".
 
int MolfileHasNoChemStruc (MOL_FMT_DATA *mfdata)
 Check if the MOL file has no chemical structure.
 
int MolfileSaveCopy (INCHI_IOSTREAM *inp_file, long fPtrStart, long fPtrEnd, FILE *outfile, long num)
 Copy MOL-formatted data of SDF record or Molfile to another file.
 
int MolfileGetXYZDimAndNormFactors (MOL_FMT_DATA *mfdata, int find_norm_factors, double *x0, double *y0, double *z0, double *xmin, double *ymin, double *zmin, double *scaler, int *err, char *pStrErr)
 Get xyz dimensionality and normalization factors in the MOL file.
 
MOL_FMT_DATAFreeMolfileData (MOL_FMT_DATA *mfdata)
 Free MOL file data structure.
 

Macro Definition Documentation

◆ MAX_STDATA_AVE_BOND_LENGTH

#define MAX_STDATA_AVE_BOND_LENGTH   20.0

◆ MAX_STDATA_X_COORD

#define MAX_STDATA_X_COORD   256.0

◆ MAX_STDATA_Y_COORD

#define MAX_STDATA_Y_COORD   256.0

◆ MAX_STDATA_Z_COORD

#define MAX_STDATA_Z_COORD   256.0

◆ MIN_STDATA_AVE_BOND_LENGTH

#define MIN_STDATA_AVE_BOND_LENGTH   10.0

◆ MIN_STDATA_X_COORD

#define MIN_STDATA_X_COORD   0.0

◆ MIN_STDATA_Y_COORD

#define MIN_STDATA_Y_COORD   0.0

◆ MIN_STDATA_Z_COORD

#define MIN_STDATA_Z_COORD   0.0

Function Documentation

◆ FreeMolfileData()

MOL_FMT_DATA * FreeMolfileData ( MOL_FMT_DATA mfdata)

Free MOL file data structure.

Parameters
mfdataPointer to the MOL file data structure to free.
Returns
NULL pointer.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ MolfileExtractStrucNum()

long MolfileExtractStrucNum ( MOL_FMT_HEADER_BLOCK pHdr)

Extract the MOL file number from the header name line like "Structure #22".

Parameters
pHdrPointer to the header block.
Returns
The structure number.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ MolfileGetXYZDimAndNormFactors()

int MolfileGetXYZDimAndNormFactors ( MOL_FMT_DATA mfdata,
int  find_norm_factors,
double *  x0,
double *  y0,
double *  z0,
double *  xmin,
double *  ymin,
double *  zmin,
double *  scaler,
int *  err,
char *  pStrErr 
)

Get xyz dimensionality and normalization factors in the MOL file.

Parameters
mfdataPointer to the MOL file data structure.
find_norm_factorsFlag indicating whether to find normalization/scaling factors.
x0Pointer to the minimum x-coordinate of the molecule.
y0Pointer to the minimum y-coordinate of the molecule.
z0Pointer to the minimum z-coordinate of the molecule.
xminPointer to the x-coordinate (is set to 0).
yminPointer to the y-coordinate (is set to 0).
zminPointer to the z-coordinate (is set to 0).
scalerPointer to the scaling factor.
errPointer to the error code.
pStrErrPointer to the error string buffer.
Returns
number of dimensions: 0, 2, 3
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ MolfileHasNoChemStruc()

int MolfileHasNoChemStruc ( MOL_FMT_DATA mfdata)

Check if the MOL file has no chemical structure.

Parameters
mfdataPointer to the MOL file data structure.
Returns
1 if no chemical structure, 0 otherwise.
+ Here is the caller graph for this function:

◆ MolfileReadField()

int MolfileReadField ( void *  data,
int  field_len,
int  data_type,
char **  line_ptr 
)

Extract the 'data' in the MOL file field at given text position 'line_ptr'.

Parameters
dataPointer to the destination buffer.
field_lenLength of the field to read. For MOL_FMT_STRING_DATA does not include trailing zero, that is actual length of the string pointed by 'data' should be at least field_len+1 bytes. For numerical data 'field_len' is length of input data field For numerical integral data field_len <= 0 means read up to first non-numeric character as strtod() does ("free format")
data_typeType of the data to read. E.g. MOL_FMT_STRING_DATA, MOL_FMT_CHAR_INT_DATA, etc.
line_ptrPointer to a variable that will receive the address of the next line.
Returns
for MOL_FMT_STRING_DATA: number of bytes excluding trailing zero for all others: 1=success; 0 = empty; -1 = error

on exit *line_ptr points to the next byte after the last entered

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ MolfileSaveCopy()

int MolfileSaveCopy ( INCHI_IOSTREAM inp_file,
long  fPtrStart,
long  fPtrEnd,
FILE *  outfile,
long  num 
)

Copy MOL-formatted data of SDF record or Molfile to another file.

Parameters
inp_filePointer to the input file stream.
fPtrStartFile pointer position to start copying from.
fPtrEndFile pointer position to stop copying at.
outfilePointer to the output file stream.
numStructure number to write in the header line.
Returns
last position of the output file stream.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ MolfileStrnread()

int MolfileStrnread ( char *  dest,
char *  source,
int  len,
char **  first_space 
)

Read a string from a source buffer into a destination buffer.

Parameters
destPointer to the destination buffer.
sourcePointer to the source buffer.
lenLength of the string to read.
first_spacePointer to a variable that will receive the address of the first space character in the source buffer.
Returns
number of actually processed bytes excluding zero terminator.
+ Here is the caller graph for this function: