/* MIT License Copyright (c) 2018 Nataliya Timoshevskaya, Department of Biology, University of Kentucky Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /* SparseGenotyping - is a program that allows to define a consensus genotype for scaffolds based on low-coverage SNP calls by accumulating number of reads that support one or another genotype across the length of a scaffold Compilation g++ SparseGenotyping.cpp -o SparseGenotyping Usage details, test data and updates can be found at https://github.com/timnat/SparseGenotyping */ #include #include #include #include #include #include #include #include using namespace std; #define TT 1000 #define NInd 50 //NInd is a number of individuals/samples in vcf file. Notice, that in our study genotypes of first two (F=2) individuals were not computed, as they were known and used as a control in the original study; genotypes are computed for 48 individuals. Someone have to change NInd and F according to the given vcf file and purposes of their study and recompile the program. #define F 2 //------------------------------------------- int extractAM_AT(int i, string g, int* AM, int *AT) {string s_genotype,s_AM, s_AT; //cout << "g_"<e) return '0'; // NEW in V3 if(ratio_AM_to_sum>=min_r && ratio_AM_to_sum<=max_r) return '1'; // cout<= argc) { fprintf(stderr, "Expected vcf_file\n"); fprintf(stderr, "Usage: %s [-r min_read_number [4]] [-m min_ratio [0.25]] [-M max_ratio [0.75]] [-e homoz_min_ratio [0.8]] vcf_file\n", argv[0]); exit(EXIT_FAILURE); } strncat(fname,argv[optind],strlen(argv[optind])); printf("vcf_file: %s\nmin_read_number=%d\nmin_ratio=%.2f\nmax_ratio=%.2f\ne=%.2f\n", fname,min_read_number,min_r,max_r,e); std::ifstream infile( fname ); if (!infile) { fprintf(stderr, "Can't open vcf_file %s\n",fname); exit(EXIT_FAILURE); } //puts("prepear output files"); //-- outputs---------- sprintf(sss,"%d",min_read_number); strncat(fname,".r",2); strncat(fname,sss,strlen(sss)); sprintf(sss,"%.2f",min_r); strncat(fname,".",1); strncat(fname,sss,strlen(sss)); sprintf(sss,"%.2f",max_r); strncat(fname,"_",1); strncat(fname,sss,strlen(sss)); strncpy(sum_out,fname,strlen(fname)); cout<<"Output will be in files with prefix: "<< sum_out <=2) //skip AM in column 0, and ATT in column 1 { if (G=='0') sum_AM++, Znumber++; if (G=='1') sum_AMT++, Unumber++; if (G=='-') sum_low++, dash_number++; if (G=='~') sum_lim++, tilda_number++; } } sumf_out<=2) { if (G=='0') sum_AM++, Znumber++; if (G=='1') sum_AMT++, Unumber++; if (G=='-') sum_low++, dash_number++; if (G=='~') sum_lim++, tilda_number++; } } f_out<e)="<