#include #include #include #include #include #include "constants.h" #include "struct_TAC_in.h" #include "parse_in_akc.h" #include "get_tac_akc.h" #include "find_MAT_akc.h" #include "fit_sv_akc.h" #include "write_data_akc.h" /* C source code name: Plant_main_akc.c */ /* edit, e.g., with emacs. compile with Makefile */ /* By: Alexander K. Converse, University of Wisconsin-Madison */ /* Created: 25 May 2012 */ /* Modified: 3 March 2014 */ /* Purpose: Fit plant TACs with model */ /* 20120518 Model based on McKay et al. Plant, Cell and Environment (198) 11:851-861 */ /* B(t+dt) = dt* sv(M(t)-B(t)) + B(t) (B = trapped, M = free) */ /* B(infinite) = B(end of scan) */ /* see plant_McKay_akc_c_flow_20120518.pdf */ /* usage: $McKay_akc_dev input_file.txt output_file.txt */ struct TAC_t TAC_in; struct ROI chosenROI; struct ROI allROIs[MAXROIS]; int main(int argc, char *argv[]) { int i; int j; int MAT; int returnVal; char const *inputFile; char const *outputFile; // Check for correct input arguments if (argc < 3) { printf("Not enough input arguments\n"); printf("Usage: ./Plant_main_akc.c input_file.txt output_file.txt"); printf("Exiting program\n"); return 0; } inputFile = argv[1]; outputFile = argv[2]; // Check that strings are valid file names if ((strlen(outputFile) < 5) || strlen(inputFile) < 5) { printf("Input argument doesn't have correct file extension\n"); printf("Usage: ./Plant_main_akc.c input_file.txt output_file.txt\n"); printf("Exiting program\n"); return 0; } // Initialize a structure to hold information from input file struct TAC_t *TAC_ptr; TAC_ptr = &TAC_in; printf("input file: %s\n", inputFile); // Store input file information in structure called TAC_t returnVal = parse_in_akc(TAC_ptr, inputFile); if (returnVal == 0) { return 0; } MAT = TAC_in.MAT; // Loop through each ROI for (i = 0; i < TAC_in.nROIs; ++i) { // Find the ith ROI and store its data in allROIs[i] get_tac_akc(TAC_ptr, &allROIs[i], i); // Find optimum SV fit_sv_akc(i, &allROIs[i], TAC_ptr, MAT); // Calculate model information based on optimum sv find_MAT_akc(i, 0, &allROIs[i], TAC_ptr, allROIs[i].sv, MAT); // Write identifying information at top of file if (i == 0) { write_header_akc(&TAC_in, outputFile, MAT); } // Write ROI name, position, sv, MAT write_ROIData_akc(&allROIs[i], &TAC_in, outputFile, i); } // Write time, observed, bound, free, bound+free for (i = 0; i < TAC_in.nROIs; ++i) { write_ModelData_akc(&allROIs[i], &TAC_in, outputFile, i); } printf("\nEnd Plant_main_akc.c\n"); return 1; }