int main(int argc, char * argv[]){ /* MPI Initialization */ int nprocs, rank; MPI_Init(&argc, &argv); MPI_Comm_size(MPI_COMM_WORLD, &nprocs); MPI_Comm_rank(MPI_COMM_WORLD, &rank); if (argc!=4){ fprintf(stderr, "Usage: %s\n", argv[0]); exit(EXIT_FAILURE); } /* number of steps in mcmc */ int max_steps; /* flag to indicate starting parameters */ int param_flag; /* name of file to output -- not including path */ char file_string[256]; sscanf(argv[1], "%d", &max_steps); sscanf(argv[2], "%d", ¶m_flag); if(rank==0) fprintf(stderr, "%d steps in mcmc chain.\n", max_steps); sscanf(argv[3], "%s", file_string); /* -- Initialize parameters --*/ STEP_DATA initial; load_step_data(&initial, param_flag, rank); /* -- Load data from various files --*/ int i, j; int N_plist; int N_bins; POINTING *plist; /* have each process separately access these files */ int current_rank = 0; while ( current_rank < nprocs ){ if (current_rank == rank) { load_pointingID(&N_plist, &plist); if(rank == 0) fprintf(stderr, "%d pointings to do\n", N_plist); N_bins = load_Nbins(); if(rank == 0) fprintf(stderr, "%d bins per pointing\n", N_bins); } MPI_Barrier(MPI_COMM_WORLD); current_rank++; } /* Establish slice of pointings for each process to handle */ int slice_length; int remain = N_plist % nprocs; int lower_ind, upper_ind; /* Make slices as even as possible */ slice_length = N_plist / nprocs; lower_ind = rank * slice_length; if (rank < remain){ lower_ind += rank; slice_length++; } else lower_ind += remain; upper_ind = lower_ind + slice_length; /* Each process now loads data for its slice only */ load_ZRW(plist, lower_ind, upper_ind, rank); load_rbins(plist, N_bins, lower_ind, upper_ind, rank); load_pairs(plist, N_bins, lower_ind, upper_ind, rank); // load_covariance(plist, N_bins, lower_ind, upper_ind, rank); // load_correlation(plist, N_bins, lower_ind, upper_ind, rank); load_inv_covariance(plist, N_bins, lower_ind, upper_ind, rank); /* test loading of covariance */ // if(rank==0){ // for(i=0; i<N_bins; i++){ // for(j=0; j<N_bins; j++){ // fprintf(stderr, "Value: %le, Row: %d, Col: %d \n", // plist[1].cov_row[i].cov_col[j], i, j); // } // } // } // MPI_Barrier(MPI_COMM_WORLD); /* Calculate DD/RR */ /* Only must be done once */ calculate_DD_RR(plist, N_bins, lower_ind, upper_ind); /* Run mcmc */ run_mcmc(plist, initial, N_bins, max_steps, lower_ind, upper_ind, rank, nprocs, file_string); /* Free allocated values */ for(i=lower_ind; i<upper_ind; i++){ for(j=0; j<N_bins; j++){ free(plist[i].rbin[j].pair1); free(plist[i].rbin[j].pair2); // free(plist[i].cov_row[j].cov_col); // free(plist[i].cor_row[j].cor_col); free(plist[i].invcov_row[j].invcov_col); } free(plist[i].rbin); // free(plist[i].cov_row); // free(plist[i].cor_row); free(plist[i].invcov_row); free(plist[i].Z); free(plist[i].R); free(plist[i].weight); } free(plist); if(rank==0) fprintf(stderr, "Allocated space cleared. \n"); /* barrier to ensure all procs clear space before MPI_Finalize */ MPI_Barrier(MPI_COMM_WORLD); MPI_Finalize(); return EXIT_SUCCESS; }
int main (int argc, char* argv[]) { char filename1[200]; char filename2[200]; char pairs_file[200]; char fileout[200]; FILE* query_fp = 0; FILE* reference_fp = 0; FILE* fp_pairs = 0; FILE* fpout = stdout; int total_pairs = 0; pair_struct* pairs = 0; extern FILE *scaninfo_file; setup_match_types(); /* Set Default Parameter Values*/ length_5p_for_weighting = 8; /* The 5' sequence length to be weighted except for the last residue */ scale = 4.0; /* The 5' miRNA scaling parameter */ strict = 0; /* Strict seed model on/off*/ debug = 0; /* Debugging mode on/off*/ key_value_pairs = 0; gap_open = -9.0; /* Gap-open Penalty*/ gap_extend = -4.0; /* Gap-extend Penalty*/ score_threshold = 140.0; /* SW Score Threshold for reporting hits*/ score_ceiling = 0; /* Default upper limit to score. If zero, this is not used. */ energy_threshold = 1.0; /* Energy Threshold (DG) for reporting hits*/ verbosity = 1; /* Verbose mode on/off*/ brief_output = 0; /* Brief output off by default */ rusage_output = 0; /* rusage output off by default */ outfile = 0; /* Dump to file on/off*/ truncated = 0; /* Truncate sequences on/off*/ no_energy = 1; /* Turn off Energy Calcs - FASTER*/ restricted = 0; /* Perform restricted search space*/ parse_command_line(argc, argv, filename1, filename2, fileout, pairs_file); if (gap_open > 0.0 || gap_extend > 0.0) { fprintf(stderr, "Error: gap penalties may not be greater than 0\n"); return 1; } if (truncated < 0) { fprintf(stderr, "Error: negative value give for UTR truncation\n"); return 1; } if ((query_fp = fopen(filename1, "r")) == NULL) { fprintf(stderr, "Error: Cannot open file %s\n", filename1); return 1; } if ((reference_fp = fopen(filename2, "r")) == NULL) { fprintf(stderr, "Error: Cannot open file %s\n", filename2); return 1; } fclose(reference_fp); if ((outfile) && ((fpout = fopen(fileout, "w")) == NULL)) { fprintf(stderr, "Error: Cannot create output file %s\n", fileout); return 1; } if (restricted) { if ((fp_pairs = fopen(pairs_file, "r")) == NULL) { fprintf(stderr, "Error: Cannot open restrict pairs file %s\n", pairs_file); return 1; } /* Initialize the pairs list for restriced searches*/ total_pairs = load_pairs(fp_pairs, &pairs); fclose(fp_pairs); } fflush(fpout); initialize_globals(); if(!brief_output) print_parameters(filename1, filename2, fpout); if (restricted && verbosity) { printf("Performing Restricted Scan on:%d pairs\n", total_pairs); } find_targets(query_fp, fpout, pairs, total_pairs, filename2); #ifdef USE_RUSAGE if(rusage_output) { struct rusage ru; if(getrusage(RUSAGE_SELF,&ru) != 0) { fprintf(stderr,"Could not get rusage data\n"); if(errno) fprintf(stderr,"Reason: %s",strerror(errno)); } else { printf("User CPU time: %ld.%06ld\n",ru.ru_utime.tv_sec,ru.ru_utime.tv_usec); printf("Max RSS: %ld KB\n",ru.ru_maxrss); } } #endif // RUSAGE destroy_globals(); if (outfile) fclose(fpout); if (scaninfo_file != stdout && scaninfo_file != stderr && scaninfo_file != NULL) fclose(scaninfo_file); json_close(); fclose(query_fp); return 0; }
int main(int argc, char * argv[]){ /* MPI Initialization */ int nprocs, rank; MPI_Init(&argc, &argv); MPI_Comm_size(MPI_COMM_WORLD, &nprocs); MPI_Comm_rank(MPI_COMM_WORLD, &rank); /* parse command line for starting params, steps, and filename */ ARGS cl = parse_command_line( argc, argv ); if(rank==0){ fprintf(stderr, "N_parameters: %d\n", cl.N_params); fprintf(stderr, "Starting parameters: r0_thin = %lf , z0_thin = %lf , r0_thick = %lf , z0_thick = %lf , ratio = %lf\n", cl.r0_thin, cl.z0_thin, cl.r0_thick, cl.z0_thick, cl.ratio); fprintf(stderr, "%d steps in MCMC chain...\n", cl.max_steps); fprintf(stderr, "Results will be output to %s\n", cl.filename); } /* Assign cl arguments to initial parameters */ STEP_DATA initial; initial.r0_thin = cl.r0_thin; initial.z0_thin = cl.z0_thin; initial.r0_thick = cl.r0_thick; initial.z0_thick = cl.z0_thick; initial.ratio_thick_thin = cl.ratio; initial.chi2 = 0.0; initial.chi2_reduced = 0.0; /* -- Load data from various files --*/ int i, j; int N_plist; int N_bins; POINTING *plist; /* have each process separately access these files */ int current_rank = 0; while ( current_rank < nprocs ){ if (current_rank == rank){ load_pointingID(&N_plist, &plist); if(rank == 0) fprintf(stderr, "%d pointings to do\n", N_plist); N_bins = load_Nbins(); if(rank == 0) fprintf(stderr, "%d bins per pointing\n", N_bins); } MPI_Barrier(MPI_COMM_WORLD); current_rank++; } /* Establish slice of pointings for each process to handle */ int slice_length; int remain = N_plist % nprocs; int lower_ind, upper_ind; /* Make slices as even as possible */ slice_length = N_plist / nprocs; lower_ind = rank * slice_length; if (rank < remain){ lower_ind += rank; slice_length++; } else lower_ind += remain; upper_ind = lower_ind + slice_length; /* Each process now loads data for its slice only */ load_ZRW(plist, lower_ind, upper_ind, rank); load_rbins(plist, N_bins, lower_ind, upper_ind, rank); load_pairs(plist, N_bins, lower_ind, upper_ind, rank); load_inv_correlation(plist, N_bins, lower_ind, upper_ind, rank); /* Run mcmc */ run_mcmc(plist, cl.N_params, initial, N_bins, cl.max_steps, lower_ind, upper_ind, rank, nprocs, cl.filename); /* Free allocated values */ for(i=lower_ind; i<upper_ind; i++){ for(j=0; j<N_bins; j++){ free(plist[i].rbin[j].pair1); free(plist[i].rbin[j].pair2); } free(plist[i].rbin); free(plist[i].Z); free(plist[i].R); free(plist[i].weight); } free(plist); if(rank==0) fprintf(stderr, "Allocated space cleared. \n"); /* barrier to ensure all procs clear space before MPI_Finalize */ MPI_Barrier(MPI_COMM_WORLD); MPI_Finalize(); return EXIT_SUCCESS; }
int main(int argc, char * argv[]){ /* MPI Initialization */ int nprocs, rank; MPI_Init(&argc, &argv); MPI_Comm_size(MPI_COMM_WORLD, &nprocs); MPI_Comm_rank(MPI_COMM_WORLD, &rank); // if (argc!=4){ // fprintf(stderr, "Usage: %s\n", argv[0]); // exit(EXIT_FAILURE); // } // /* number of steps in mcmc */ // int max_steps; // /* flag to indicate starting parameters */ // int param_flag; // /* name of file to output -- not including path */ // char file_string[256]; // sscanf(argv[1], "%d", &max_steps); // sscanf(argv[2], "%d", ¶m_flag); // if(rank==0) fprintf(stderr, "%d steps in mcmc chain.\n", max_steps); // sscanf(argv[3], "%s", file_string); // /* -- Initialize parameters --*/ // STEP_DATA initial; // load_step_data(&initial, param_flag, rank); /* parse command line for starting params, steps, and filename */ ARGS cl = parse_command_line( argc, argv ); if(rank==0){ fprintf(stderr, "N_parameters: %d\n", cl.N_params); fprintf(stderr, "Starting parameters: r0_thin = %lf , z0_thin = %lf , r0_thick = %lf , z0_thick = %lf , ratio = %lf\n", cl.r0_thin, cl.z0_thin, cl.r0_thick, cl.z0_thick, cl.ratio); fprintf(stderr, "%d steps in MCMC chain...\n", cl.max_steps); fprintf(stderr, "Results will be output to %s\n", cl.filename); } /* Assign cl arguments to initial parameters */ STEP_DATA initial; initial.r0_thin = cl.r0_thin; initial.z0_thin = cl.z0_thin; initial.r0_thick = cl.r0_thick; initial.z0_thick = cl.z0_thick; initial.ratio_thick_thin = cl.ratio; initial.chi2 = 0.0; initial.chi2_reduced = 0.0; /* -- Load data from various files --*/ int i, j; int N_plist; int N_bins; POINTING *plist; /* have each process separately access these files */ int current_rank = 0; while ( current_rank < nprocs ){ if (current_rank == rank) { load_pointingID(&N_plist, &plist); if(rank == 0) fprintf(stderr, "%d pointings to do\n", N_plist); N_bins = load_Nbins(); if(rank == 0) fprintf(stderr, "%d bins per pointing\n", N_bins); } MPI_Barrier(MPI_COMM_WORLD); current_rank++; } /* Establish slice of pointings for each process to handle */ int slice_length; int remain = N_plist % nprocs; int lower_ind, upper_ind; /* Make slices as even as possible */ slice_length = N_plist / nprocs; lower_ind = rank * slice_length; if (rank < remain){ lower_ind += rank; slice_length++; } else lower_ind += remain; upper_ind = lower_ind + slice_length; /* Each process now loads data for its slice only */ load_ZRW(plist, lower_ind, upper_ind, rank); load_rbins(plist, N_bins, lower_ind, upper_ind, rank); load_pairs(plist, N_bins, lower_ind, upper_ind, rank); /* Calculate fractional error in DD/MM */ /* Only must be done once */ calculate_frac_error(plist, N_bins, lower_ind, upper_ind); /* Run mcmc */ run_mcmc(plist, cl.N_params, initial, N_bins, cl.max_steps, lower_ind, upper_ind, rank, nprocs, cl.filename); /* Free allocated values */ for(i=lower_ind; i<upper_ind; i++){ for(j=0; j<N_bins; j++){ free(plist[i].rbin[j].pair1); free(plist[i].rbin[j].pair2); } free(plist[i].rbin); free(plist[i].Z); free(plist[i].R); free(plist[i].weight); } free(plist); if(rank==0) fprintf(stderr, "Allocated space cleared. \n"); /* barrier to ensure all procs clear space before MPI_Finalize */ MPI_Barrier(MPI_COMM_WORLD); MPI_Finalize(); return EXIT_SUCCESS; }
int main (int argc, char* argv[]) { char filename1[200]; char filename2[200]; char pairs_file[200]; char fileout[200]; FILE* query_fp = 0; FILE* reference_fp = 0; FILE* fp_pairs = 0; FILE* fpout = stdout; int total_pairs = 0; pair_struct* pairs = 0; /* Set Default Parameter Values*/ length_5p_for_weighting = 8; /* The 5' sequence length to be weighed except for the last residue*/ scale = 4.0; /* The 5' miRNA scaling parameter*/ strict = 0; /* Strict seed model on/off*/ debug = 0; /* Debugging mode on/off*/ key_value_pairs = 0; gap_open = -9.0; /* Gap-open Penalty*/ gap_extend = -4.0; /* Gap-extend Penalty*/ score_threshold = 140.0; /* SW Score Threshold for reporting hits*/ energy_threshold = 1.0; /* Energy Threshold (DG) for reporting hits*/ verbosity = 1; /* Verbose mode on/off*/ outfile = 0; /* Dump to file on/off*/ truncated = 0; /* Truncate sequences on/off*/ no_energy = 0; /* Turn off Vienna Energy Calcs - FASTER*/ restricted = 0; /* Perform restricted search space*/ parse_command_line(argc, argv, filename1, filename2, fileout, pairs_file); if (gap_open > 0.0 || gap_extend > 0.0) { fprintf(stderr, "Error: gap penalties may not be greater than 0\n"); return 1; } if (truncated < 0) { fprintf(stderr, "Error: negative value give for UTR truncation\n"); return 1; } if ((query_fp = fopen(filename1, "r")) == NULL) { fprintf(stderr, "Error: Cannot open file %s\n", filename1); return 1; } if ((reference_fp = fopen(filename2, "r")) == NULL) { fprintf(stderr, "Error: Cannot open file %s\n", filename2); return 1; } fclose(reference_fp); if ((outfile) && ((fpout = fopen(fileout, "w")) == NULL)) { fprintf(stderr, "Error: Cannot create output file %s\n", fileout); return 1; } if (restricted) { if ((fp_pairs = fopen(pairs_file, "r")) == NULL) { fprintf(stderr, "Error: Cannot open restrict pairs file %s\n", pairs_file); return 1; } /* Initialize the pairs list for restriced searches*/ total_pairs = load_pairs(fp_pairs, &pairs); fclose(fp_pairs); } initialize_globals(); print_parameters(filename1, filename2, fpout); if (restricted && verbosity) { printf("Performing Restricted Scan on:%d pairs\n", total_pairs); } find_targets(query_fp, fpout, pairs, total_pairs, filename2); destroy_globals(); if (outfile) fclose(fpout); fclose(query_fp); return 0; }