#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 "ichimain.h"
#include "bcf_s.h"
Macros | |
#define | ALIASED_AT(i) (0 < NUM_ISO_H(at, i)) |
#define | IS_DEUTERIUM(i) (!strcmp(at[i].elname, "D") || at[i].iso_atw_diff == 2 && !strcmp(at[i].elname, "H")) |
#define | IS_TRITIUM(i) (!strcmp(at[i].elname, "T") || at[i].iso_atw_diff == 3 && !strcmp(at[i].elname, "H")) |
#define | ABNORMAL_ISO(i) (at[i].iso_atw_diff == 1 || at[i].iso_atw_diff < -3 || at[i].iso_atw_diff > 5) |
#define | ABNORMAL_CHG(i) (abs(at[i].charge) > 3) |
#define | ABNORMAL_RAD(i) (RADICAL_SINGLET <= at[i].radical && at[i].radical <= RADICAL_TRIPLET) |
#define | ANY_ISO(i, X) |
#define | ANY_CHG(i) (0 != at[i].charge) |
#define | ANY_RAD(i) (RADICAL_SINGLET <= at[i].radical && at[i].radical <= RADICAL_TRIPLET) |
#define | NORMAL_ISO(i, X) (ANY_ISO(i, X) && !ABNORMAL_ISO(i)) |
#define | ABNORMAL_AT(i) |
#define | ADD_LINE_AT(i) |
Enumerations | |
enum | { SDF_START , SDF_DATA_HEADER , SDF_DATA_HEADER_NAME , SDF_DATA_HEADER_COMMENT , SDF_DATA_HEADER_CAS , SDF_DATA_HEADER_USER , SDF_DATA_LINE , SD_FMT_END_OF_DATA_ITEM , SDF_EMPTY_LINE , SD_FMT_END_OF_DATA_BLOCK } |
Functions | |
int | OrigAtData_WriteToSDfileHeaderAndCountThings (const ORIG_ATOM_DATA *inp_at_data, INCHI_IOSTREAM *fcb, const char *name, const char *comment, int bChiralFlag, int bAtomsDT, const char *szLabel, const char *szValue, int *nNumAliasLines, int *nNumChargeLines, int *nNumRadicalLines, int *nNumIsoLines, int *nNumAddLines, int *num_bonds) |
int | OrigAtData_WriteToSDfileAtomsBlock (const ORIG_ATOM_DATA *inp_at_data, INCHI_IOSTREAM *fcb, const char *name, const char *comment, int bAtomsDT, const char *szLabel, const char *szValue) |
int | OrigAtData_WriteToSDfileBondsBlock (const ORIG_ATOM_DATA *inp_at_data, INCHI_IOSTREAM *fcb, const char *name, const char *comment, const char *szLabel, const char *szValue, INT_ARRAY *written_bond_ends) |
int | OrigAtData_WriteToSDfileAdditionalLines (const ORIG_ATOM_DATA *inp_at_data, INCHI_IOSTREAM *fcb, const char *name, const char *comment, int bAtomsDT, const char *szLabel, const char *szValue, int nNumAliasLines, int nNumChargeLines, int nNumRadicalLines, int nNumIsoLines, INT_ARRAY *written_bond_ends) |
int | OrigAtData_WriteToSDfilePolymerData (const ORIG_ATOM_DATA *inp_at_data, INCHI_IOSTREAM *fcb, const char *name, const char *comment, const char *szLabel, const char *szValue, INT_ARRAY *written_bond_ends) |
int | SDFileSkipExtraData (INCHI_IOSTREAM *inp_file, unsigned long *CAS_num, char *comment, int lcomment, char *name, int lname, int prev_err, const char *pSdfLabel, char *pSdfValue, char *pStrErr, int bNoWarnings) |
int | SDFileIdentifyLabel (char *inp_line, const char *pSdfLabel) |
unsigned long | SDFileExtractCASNo (char *line) |
int | NumLists_Alloc (NUM_LISTS *num_lists, int nlists) |
Allocates memory for a specified number of numeric lists. | |
int | NumLists_ReAlloc (NUM_LISTS *num_lists) |
Reallocates memory for the numeric lists. | |
int | NumLists_Append (NUM_LISTS *num_lists, int *list) |
Push new item to the end of array. | |
void | NumLists_Free (NUM_LISTS *num_lists) |
Frees the memory allocated for the numeric list. | |
int | IntArray_Alloc (INT_ARRAY *items, int nitems) |
Initializes an INT_ARRAY structure. | |
int | IntArray_ReAlloc (INT_ARRAY *items) |
Reallocates memory for the INT_ARRAY structure. | |
int | IntArray_Append (INT_ARRAY *items, int new_item) |
Appends a new item to the INT_ARRAY structure. | |
int | IntArray_AppendIfAbsent (INT_ARRAY *items, int new_item) |
Appends a new item to the INT_ARRAY structure if it is not already present. | |
void | IntArray_DebugPrint (INT_ARRAY *items) |
Prints the contents of the INT_ARRAY structure for debugging purposes. | |
void | IntArray_Reset (INT_ARRAY *items) |
Resets the INT_ARRAY structure to its initial state. | |
void | IntArray_Free (INT_ARRAY *items) |
Frees the memory allocated for the INT_ARRAY structure. | |
int | MolFmtSgroup_Create (MOL_FMT_SGROUP **sgroup, int id, int type) |
Allocate new array Sgroup. | |
void | MolFmtSgroup_Free (MOL_FMT_SGROUP *sgroup) |
Frees the memory allocated for the Sgroup. | |
int | MolFmtSgroups_Alloc (MOL_FMT_SGROUPS *sgroups, int nsgroups) |
Allocates memory for a specified number of Sgroup objects. | |
int | MolFmtSgroups_ReAlloc (MOL_FMT_SGROUPS *sgroups) |
Expand array of Sgroups. | |
int | MolFmtSgroups_Append (MOL_FMT_SGROUPS *sgroups, int id, int type) |
Appends a new Sgroup to the array. | |
void | MolFmtSgroups_Free (MOL_FMT_SGROUPS *sgroups) |
Frees the memory allocated for the MOL_FMT_SGROUPS list. | |
int | MolFmtSgroups_GetIndexBySgroupId (int id, MOL_FMT_SGROUPS *sgroups) |
Gets the index of a Sgroup by its ID. | |
int | OrigAtData_WriteToSDfile (const ORIG_ATOM_DATA *inp_at_data, INCHI_IOSTREAM *fcb, const char *name, const char *comment, int bChiralFlag, int bAtomsDT, const char *szLabel, const char *szValue) |
Variables | |
static const char | sdf_data_hdr_name [] = "NAME" |
static const char | sdf_data_hdr_comm [] = "COMMENT" |
#define ABNORMAL_AT | ( | i | ) |
#define ABNORMAL_CHG | ( | i | ) | (abs(at[i].charge) > 3) |
#define ABNORMAL_ISO | ( | i | ) | (at[i].iso_atw_diff == 1 || at[i].iso_atw_diff < -3 || at[i].iso_atw_diff > 5) |
#define ABNORMAL_RAD | ( | i | ) | (RADICAL_SINGLET <= at[i].radical && at[i].radical <= RADICAL_TRIPLET) |
#define ADD_LINE_AT | ( | i | ) |
#define ALIASED_AT | ( | i | ) | (0 < NUM_ISO_H(at, i)) |
#define ANY_CHG | ( | i | ) | (0 != at[i].charge) |
#define ANY_ISO | ( | i, | |
X | |||
) |
#define ANY_RAD | ( | i | ) | (RADICAL_SINGLET <= at[i].radical && at[i].radical <= RADICAL_TRIPLET) |
#define IS_DEUTERIUM | ( | i | ) | (!strcmp(at[i].elname, "D") || at[i].iso_atw_diff == 2 && !strcmp(at[i].elname, "H")) |
#define IS_TRITIUM | ( | i | ) | (!strcmp(at[i].elname, "T") || at[i].iso_atw_diff == 3 && !strcmp(at[i].elname, "H")) |
#define NORMAL_ISO | ( | i, | |
X | |||
) | (ANY_ISO(i, X) && !ABNORMAL_ISO(i)) |
anonymous enum |
int IntArray_Alloc | ( | INT_ARRAY * | items, |
int | nitems | ||
) |
Initializes an INT_ARRAY structure.
items | Pointer to the INT_ARRAY structure to initialize. |
nitems | Initial number of items to allocate. |
int IntArray_Append | ( | INT_ARRAY * | items, |
int | new_item | ||
) |
Appends a new item to the INT_ARRAY structure.
items | Pointer to the INT_ARRAY structure to modify. |
new_item | The new item to append. |
int IntArray_AppendIfAbsent | ( | INT_ARRAY * | items, |
int | new_item | ||
) |
Appends a new item to the INT_ARRAY structure if it is not already present.
items | Pointer to the INT_ARRAY structure to modify. |
new_item | The new item to append. |
void IntArray_DebugPrint | ( | INT_ARRAY * | items | ) |
Prints the contents of the INT_ARRAY structure for debugging purposes.
items | Pointer to the INT_ARRAY structure to print. |
void IntArray_Free | ( | INT_ARRAY * | items | ) |
Frees the memory allocated for the INT_ARRAY structure.
items | Pointer to the INT_ARRAY structure to free. |
int IntArray_ReAlloc | ( | INT_ARRAY * | items | ) |
Reallocates memory for the INT_ARRAY structure.
items | Pointer to the INT_ARRAY structure to reallocate. |
void IntArray_Reset | ( | INT_ARRAY * | items | ) |
Resets the INT_ARRAY structure to its initial state.
items | Pointer to the INT_ARRAY structure to reset. |
int MolFmtSgroup_Create | ( | MOL_FMT_SGROUP ** | sgroup, |
int | id, | ||
int | type | ||
) |
Allocate new array Sgroup.
sgroup | Pointer to the Sgroup structure to allocate. |
id | Sgroup ID. |
type | Sgroup type. |
void MolFmtSgroup_Free | ( | MOL_FMT_SGROUP * | sgroup | ) |
Frees the memory allocated for the Sgroup.
sgroup | Pointer to the Sgroup structure to free. |
int MolFmtSgroups_Alloc | ( | MOL_FMT_SGROUPS * | items, |
int | nitems | ||
) |
Allocates memory for a specified number of Sgroup objects.
items | Pointer to the MOL_FMT_SGROUPS structure. |
nitems | Number of Sgroup objects to allocate. |
int MolFmtSgroups_Append | ( | MOL_FMT_SGROUPS * | items, |
int | id, | ||
int | type | ||
) |
Appends a new Sgroup to the array.
items | Pointer to the MOL_FMT_SGROUPS structure. |
id | Sgroup ID. |
type | Sgroup type. |
void MolFmtSgroups_Free | ( | MOL_FMT_SGROUPS * | items | ) |
Frees the memory allocated for the MOL_FMT_SGROUPS list.
items | Pointer to the MOL_FMT_SGROUPS structure. |
int MolFmtSgroups_GetIndexBySgroupId | ( | int | id, |
MOL_FMT_SGROUPS * | items | ||
) |
Gets the index of a Sgroup by its ID.
id | Sgroup ID. |
items | Pointer to the MOL_FMT_SGROUPS structure. |
int MolFmtSgroups_ReAlloc | ( | MOL_FMT_SGROUPS * | items | ) |
Expand array of Sgroups.
items | Pointer to the MOL_FMT_SGROUPS structure. |
int NumLists_Alloc | ( | NUM_LISTS * | num_lists, |
int | nlists | ||
) |
Allocates memory for a specified number of numeric lists.
num_lists | Pointer to the NUM_LISTS structure. |
nlists | Number of lists to allocate. |
int NumLists_Append | ( | NUM_LISTS * | num_lists, |
int * | list | ||
) |
Push new item to the end of array.
num_lists | Pointer to the NUM_LISTS structure. |
list | Pointer to the list of integers to append. |
void NumLists_Free | ( | NUM_LISTS * | num_lists | ) |
Frees the memory allocated for the numeric list.
num_lists | Pointer to the NUM_LISTS structure. |
int NumLists_ReAlloc | ( | NUM_LISTS * | num_lists | ) |
Reallocates memory for the numeric lists.
num_lists | Pointer to the NUM_LISTS structure. |
int OrigAtData_WriteToSDfile | ( | const ORIG_ATOM_DATA * | inp_at_data, |
INCHI_IOSTREAM * | fcb, | ||
const char * | name, | ||
const char * | comment, | ||
int | bChiralFlag, | ||
int | bAtomsDT, | ||
const char * | szLabel, | ||
const char * | szValue | ||
) |
int OrigAtData_WriteToSDfileAdditionalLines | ( | const ORIG_ATOM_DATA * | inp_at_data, |
INCHI_IOSTREAM * | fcb, | ||
const char * | name, | ||
const char * | comment, | ||
int | bAtomsDT, | ||
const char * | szLabel, | ||
const char * | szValue, | ||
int | nNumAliasLines, | ||
int | nNumChargeLines, | ||
int | nNumRadicalLines, | ||
int | nNumIsoLines, | ||
INT_ARRAY * | written_bond_ends | ||
) |
int OrigAtData_WriteToSDfileAtomsBlock | ( | const ORIG_ATOM_DATA * | inp_at_data, |
INCHI_IOSTREAM * | fcb, | ||
const char * | name, | ||
const char * | comment, | ||
int | bAtomsDT, | ||
const char * | szLabel, | ||
const char * | szValue | ||
) |
int OrigAtData_WriteToSDfileBondsBlock | ( | const ORIG_ATOM_DATA * | inp_at_data, |
INCHI_IOSTREAM * | fcb, | ||
const char * | name, | ||
const char * | comment, | ||
const char * | szLabel, | ||
const char * | szValue, | ||
INT_ARRAY * | written_bond_ends | ||
) |
int OrigAtData_WriteToSDfileHeaderAndCountThings | ( | const ORIG_ATOM_DATA * | inp_at_data, |
INCHI_IOSTREAM * | fcb, | ||
const char * | name, | ||
const char * | comment, | ||
int | bChiralFlag, | ||
int | bAtomsDT, | ||
const char * | szLabel, | ||
const char * | szValue, | ||
int * | nNumAliasLines, | ||
int * | nNumChargeLines, | ||
int * | nNumRadicalLines, | ||
int * | nNumIsoLines, | ||
int * | nNumAddLines, | ||
int * | num_bonds | ||
) |
Important: Atoms with alias cannot have charge, radical
isotope differences are allowed
Atoms with alias cannot be abnormal.
Abnormal atoms are atoms which need M CHG, M RAD, M ISO
Output aliased atoms if they have implicit D or T
int OrigAtData_WriteToSDfilePolymerData | ( | const ORIG_ATOM_DATA * | inp_at_data, |
INCHI_IOSTREAM * | fcb, | ||
const char * | name, | ||
const char * | comment, | ||
const char * | szLabel, | ||
const char * | szValue, | ||
INT_ARRAY * | written_bond_ends | ||
) |
unsigned long SDFileExtractCASNo | ( | char * | line | ) |
int SDFileIdentifyLabel | ( | char * | inp_line, |
const char * | pSdfLabel | ||
) |
int SDFileSkipExtraData | ( | INCHI_IOSTREAM * | inp_file, |
unsigned long * | CAS_num, | ||
char * | comment, | ||
int | lcomment, | ||
char * | name, | ||
int | lname, | ||
int | prev_err, | ||
const char * | pSdfLabel, | ||
char * | pSdfValue, | ||
char * | pStrErr, | ||
int | bNoWarnings | ||
) |
|
static |
|
static |