/* ## ## ######### ## ########## ########## ### ### ## ########## ## #### #### ## ########## ## ## ## ## ## ## ## ########## ## ######## ## ## ## ## ## ## ###### ######## ## ## ## ## ## ###### ### ## ## ## ############## ## ### ## ########## ## ############## ## ### ################# ######## ## ########### ######### ## ######### ## ########### ## ## ## ### ## ########## ## ## ## ###### ## ## ########## ## ## ## ###### ######## ## # ## ## ######### ## # ## ## ## ## ## ### ########## ## ## ## ### ########## ########## ######### */ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ** ** ** ** ** E N S E M B L E ** ** ** ** Version 2.1 ** ** ** ** ** ** Principal Investigator: Julie D. Forman-Kay ** ** ** ** Author: Mickaƫl Krzeminski ** ** ** ** Date: November 2012 ** ** ** ** ** ************************************************************************************* ** ** ** ** ** Copyright (C) The Hospital for Sick Children, 2001 ** ** ** ** Distribution of substantively modified versions of this module is prohibited ** ** without the explicit permission of the copyright holder. ** ** ** ** Any use of this work or derivative works in whole or in part for any ** ** commercial purpose or for monetary gain is prohibited. ** ** ** ** ** ** NO WARRANTY ** ** This software package is provided 'as is' without warranty of any kind, ** ** expressed or implied. ** ** ** ** ** * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * \* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* COMPILATION gcc -O3 -lm -o read_best read_best.c */ #include "Include/ens.h" enum toolsPrograms TP = __READ_BEST__; int main(int argc, char *argv[]) { /***********************************************************\ |* *| |* *| |* Variables declaration *| |* *| |* *| \***********************************************************/ counter bestEnsNb; char type[4] = {'\0'}; uint32_t nbBestEns, runNb, trialNb; unsigned short doubleSize; FILE *ENSFile; /***********************************************************\ |* *| |* *| |* Reading the Best file type *| |* *| |* *| \***********************************************************/ // Checking arguments if (argc < 2) { __USAGE__ } // Attempting to open the specified file if ((ENSFile = fopen(argv[1], "rb")) == NULL) { fatal_error("NO_FILE", argv[1]); } /* The best ensemble file type contains the following information: 0. The file type (Character: 'Bes') 1. Size of a double variable (Unsigned Short) 2. Number of best ensembles (Unsigned Integer) 2.a. Run number (Unsigned Long Integer) 2.b. Trial number (Unsigned Long Integer) 2.c. Number of conformers (Unsigned Long Integer) 2.c.a Conformer numbers (Unsigned Long Integers) 2.d. Effective total energy (Double Float) 2.e. Number of modules (Unsigned Short) 2.e.a. Module code (Unsigned Short) 2.e.b. Effective energy (Double Float) 2.e.c. Target energy (Double Float) 2.e.d. ENSEMBLE energy (Double Float) */ // File type fread(&type, CHAR_SIZE, 3, ENSFile); if (strcmp(type, "Bes")) { fclose(ENSFile); fatal_error("BEST_FILE", argv[1]); } // Size of a double data at the time it was recorded by the PERL script fread(&doubleSize, SHORT_SIZE, 1, ENSFile); if (doubleSize != sizeof(double)) { fclose(ENSFile); fatal_error("The specified file was generated on a different machine type.", NULL); } // Number of best ensembles fread(&nbBestEns, INT32_SIZE, 1, ENSFile); if (!nbBestEns) { fclose(ENSFile); printf("The specified file contains no best ensemble.\n\n"); exit(0); } printf ("Number of best ensembles: %u\n\n", nbBestEns); for (bestEnsNb=0; bestEnsNb