InChI
 
Loading...
Searching...
No Matches
mol_fmt4.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 "ichimain.h"
#include "bcf_s.h"
+ Include dependency graph for mol_fmt4.c:

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"
 

Macro Definition Documentation

◆ ABNORMAL_AT

#define ABNORMAL_AT (   i)
Value:
(at[i].radical || abs(at[i].charge) > 3 || \
ABNORMAL_ISO(i))

◆ ABNORMAL_CHG

#define ABNORMAL_CHG (   i)    (abs(at[i].charge) > 3)

◆ ABNORMAL_ISO

#define ABNORMAL_ISO (   i)    (at[i].iso_atw_diff == 1 || at[i].iso_atw_diff < -3 || at[i].iso_atw_diff > 5)

◆ ABNORMAL_RAD

#define ABNORMAL_RAD (   i)    (RADICAL_SINGLET <= at[i].radical && at[i].radical <= RADICAL_TRIPLET)

◆ ADD_LINE_AT

#define ADD_LINE_AT (   i)
Value:
(at[i].charge || \
at[i].radical || \
at[i].iso_atw_diff && (bAtomsDT ? (at[i].iso_atw_diff != 1 || strcmp(at[i].elname, "H")) : 1))

◆ ALIASED_AT

#define ALIASED_AT (   i)    (0 < NUM_ISO_H(at, i))

◆ ANY_CHG

#define ANY_CHG (   i)    (0 != at[i].charge)

◆ ANY_ISO

#define ANY_ISO (   i,
 
)
Value:
((X)? (at[i].iso_atw_diff && !IS_DEUTERIUM(i) && !IS_TRITIUM(i)) :\
(at[i].iso_atw_diff || IS_DEUTERIUM(i) || IS_TRITIUM(i)))
#define IS_TRITIUM(i)
Definition mol_fmt4.c:65
#define IS_DEUTERIUM(i)
Definition mol_fmt4.c:64

◆ ANY_RAD

#define ANY_RAD (   i)    (RADICAL_SINGLET <= at[i].radical && at[i].radical <= RADICAL_TRIPLET)

◆ IS_DEUTERIUM

#define IS_DEUTERIUM (   i)    (!strcmp(at[i].elname, "D") || at[i].iso_atw_diff == 2 && !strcmp(at[i].elname, "H"))

◆ IS_TRITIUM

#define IS_TRITIUM (   i)    (!strcmp(at[i].elname, "T") || at[i].iso_atw_diff == 3 && !strcmp(at[i].elname, "H"))

◆ NORMAL_ISO

#define NORMAL_ISO (   i,
 
)    (ANY_ISO(i, X) && !ABNORMAL_ISO(i))

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
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 

Function Documentation

◆ IntArray_Alloc()

int IntArray_Alloc ( INT_ARRAY items,
int  nitems 
)

Initializes an INT_ARRAY structure.

Parameters
itemsPointer to the INT_ARRAY structure to initialize.
nitemsInitial number of items to allocate.
Returns
0 on success, -1 on failure.
+ Here is the caller graph for this function:

◆ IntArray_Append()

int IntArray_Append ( INT_ARRAY items,
int  new_item 
)

Appends a new item to the INT_ARRAY structure.

Parameters
itemsPointer to the INT_ARRAY structure to modify.
new_itemThe new item to append.
Returns
0 on success, -1 on failure.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ IntArray_AppendIfAbsent()

int IntArray_AppendIfAbsent ( INT_ARRAY items,
int  new_item 
)

Appends a new item to the INT_ARRAY structure if it is not already present.

Parameters
itemsPointer to the INT_ARRAY structure to modify.
new_itemThe new item to append.
Returns
0 on success, -1 on failure.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ IntArray_DebugPrint()

void IntArray_DebugPrint ( INT_ARRAY items)

Prints the contents of the INT_ARRAY structure for debugging purposes.

Parameters
itemsPointer to the INT_ARRAY structure to print.
+ Here is the caller graph for this function:

◆ IntArray_Free()

void IntArray_Free ( INT_ARRAY items)

Frees the memory allocated for the INT_ARRAY structure.

Parameters
itemsPointer to the INT_ARRAY structure to free.
+ Here is the caller graph for this function:

◆ IntArray_ReAlloc()

int IntArray_ReAlloc ( INT_ARRAY items)

Reallocates memory for the INT_ARRAY structure.

Parameters
itemsPointer to the INT_ARRAY structure to reallocate.
Returns
0 on success, -1 on failure.
+ Here is the caller graph for this function:

◆ IntArray_Reset()

void IntArray_Reset ( INT_ARRAY items)

Resets the INT_ARRAY structure to its initial state.

Parameters
itemsPointer to the INT_ARRAY structure to reset.
+ Here is the caller graph for this function:

◆ MolFmtSgroup_Create()

int MolFmtSgroup_Create ( MOL_FMT_SGROUP **  sgroup,
int  id,
int  type 
)

Allocate new array Sgroup.

Parameters
sgroupPointer to the Sgroup structure to allocate.
idSgroup ID.
typeSgroup type.
Returns
0 on success, -1 on failure.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ MolFmtSgroup_Free()

void MolFmtSgroup_Free ( MOL_FMT_SGROUP sgroup)

Frees the memory allocated for the Sgroup.

Parameters
sgroupPointer to the Sgroup structure to free.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ MolFmtSgroups_Alloc()

int MolFmtSgroups_Alloc ( MOL_FMT_SGROUPS items,
int  nitems 
)

Allocates memory for a specified number of Sgroup objects.

Parameters
itemsPointer to the MOL_FMT_SGROUPS structure.
nitemsNumber of Sgroup objects to allocate.
Returns
0 on success, -1 on failure.
+ Here is the caller graph for this function:

◆ MolFmtSgroups_Append()

int MolFmtSgroups_Append ( MOL_FMT_SGROUPS items,
int  id,
int  type 
)

Appends a new Sgroup to the array.

Parameters
itemsPointer to the MOL_FMT_SGROUPS structure.
idSgroup ID.
typeSgroup type.
Returns
0 on success, -1 on failure.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ MolFmtSgroups_Free()

void MolFmtSgroups_Free ( MOL_FMT_SGROUPS items)

Frees the memory allocated for the MOL_FMT_SGROUPS list.

Parameters
itemsPointer to the MOL_FMT_SGROUPS structure.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ MolFmtSgroups_GetIndexBySgroupId()

int MolFmtSgroups_GetIndexBySgroupId ( int  id,
MOL_FMT_SGROUPS items 
)

Gets the index of a Sgroup by its ID.

Parameters
idSgroup ID.
itemsPointer to the MOL_FMT_SGROUPS structure.
Returns
Index of the Sgroup on success, -1 on failure.
+ Here is the caller graph for this function:

◆ MolFmtSgroups_ReAlloc()

int MolFmtSgroups_ReAlloc ( MOL_FMT_SGROUPS items)

Expand array of Sgroups.

Parameters
itemsPointer to the MOL_FMT_SGROUPS structure.
Returns
0 on success, -1 on failure.
+ Here is the caller graph for this function:

◆ NumLists_Alloc()

int NumLists_Alloc ( NUM_LISTS num_lists,
int  nlists 
)

Allocates memory for a specified number of numeric lists.

Parameters
num_listsPointer to the NUM_LISTS structure.
nlistsNumber of lists to allocate.
Returns
0 on success, -1 on failure.
+ Here is the caller graph for this function:

◆ NumLists_Append()

int NumLists_Append ( NUM_LISTS num_lists,
int *  list 
)

Push new item to the end of array.

Parameters
num_listsPointer to the NUM_LISTS structure.
listPointer to the list of integers to append.
Returns
0 on success, -1 on failure.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ NumLists_Free()

void NumLists_Free ( NUM_LISTS num_lists)

Frees the memory allocated for the numeric list.

Parameters
num_listsPointer to the NUM_LISTS structure.
+ Here is the caller graph for this function:

◆ NumLists_ReAlloc()

int NumLists_ReAlloc ( NUM_LISTS num_lists)

Reallocates memory for the numeric lists.

Parameters
num_listsPointer to the NUM_LISTS structure.
Returns
0 on success, -1 on failure.
+ Here is the caller graph for this function:

◆ OrigAtData_WriteToSDfile()

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 
)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ OrigAtData_WriteToSDfileAdditionalLines()

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 
)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ OrigAtData_WriteToSDfileAtomsBlock()

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 
)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ OrigAtData_WriteToSDfileBondsBlock()

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 
)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ OrigAtData_WriteToSDfileHeaderAndCountThings()

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

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

◆ OrigAtData_WriteToSDfilePolymerData()

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 
)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ SDFileExtractCASNo()

unsigned long SDFileExtractCASNo ( char *  line)
+ Here is the caller graph for this function:

◆ SDFileIdentifyLabel()

int SDFileIdentifyLabel ( char *  inp_line,
const char *  pSdfLabel 
)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ SDFileSkipExtraData()

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 
)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ sdf_data_hdr_comm

const char sdf_data_hdr_comm[] = "COMMENT"
static

◆ sdf_data_hdr_name

const char sdf_data_hdr_name[] = "NAME"
static