/* ## ## ######### ## ########## ########## ### ### ## ########## ## #### #### ## ########## ## ## ## ## ## ## ## ########## ## ######## ## ## ## ## ## ## ###### ######## ## ## ## ## ## ###### ### ## ## ## ############## ## ### ## ########## ## ############## ## ### ################# ######## ## ########### ######### ## ######### ## ########### ## ## ## ### ## ########## ## ## ## ###### ## ## ########## ## ## ## ###### ######## ## # ## ## ######### ## # ## ## ## ## ## ### ########## ## ## ## ### ########## ########## ######### */ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ** ** ** ** ** 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 -Wall -lm -o read_ens read_ens.c */ #include "Include/ens.h" enum toolsPrograms TP = __READ_ENS__; int main(int argc, char *argv[]) { /***********************************************************\ |* *| |* *| |* Variables declaration *| |* *| |* *| \***********************************************************/ char type[4] = {'\0'}; short nbDataTypes; unsigned short doubleSize; uint32_t nbConfs; unsigned long fileSize, expFileSize; FILE *ENSFile; /***********************************************************\ |* *| |* *| |* Reading the Energy 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]); } // Size of the file fseek(ENSFile, 0, SEEK_END); fileSize = ftell(ENSFile); if (fileSize == 0) { error("EMPTY", argv[1]); } fseek(ENSFile, 0, SEEK_SET); // Going back to the beginning of the file // File type fread(&type, CHAR_SIZE, 3, ENSFile); if (strcmp(type, "Ens")) { fatal_error("ENS_FILE", argv[1]); } // Size of a double data at the time it was recorded in the PERL script fread(&doubleSize, SHORT_SIZE, 1, ENSFile); if (doubleSize != sizeof(double)) { fatal_error("The specified file has been generated on a different machine type.", NULL); } // Number of conformers fread(&nbConfs, INT32_SIZE, 1, ENSFile); // Number of data types fseek(ENSFile, nbConfs*INT32_SIZE+DOUBLE_SIZE, SEEK_CUR); // Ignoring all selected conformers and the effective energy fread(&nbDataTypes, SHORT_SIZE, 1, ENSFile); if (!nbDataTypes) { printf ("The specified file does not contain any information.\n\n"); exit(0); } // Checking the file size expFileSize = 3 * CHAR_SIZE + 2 * SHORT_SIZE + (nbConfs + 1) * INT32_SIZE + DOUBLE_SIZE + nbDataTypes * (SHORT_SIZE + 2 * DOUBLE_SIZE); if (expFileSize != fileSize) { fatal_error("CORR_FILE", argv[1]); } fseek(ENSFile, 3*CHAR_SIZE+SHORT_SIZE, SEEK_SET); displayReadConfs(ENSFile); displayReadNrg(ENSFile); return 0; }