SOAPsnpZ/0000755000105300010600000000000011206450046012335 5ustar yuchangyuchangSOAPsnpZ/.project0000644000105300010600000000460511206446367014024 0ustar yuchangyuchang SOAPsnpZ org.eclipse.cdt.managedbuilder.core.genmakebuilder clean,full,incremental, ?name? org.eclipse.cdt.make.core.append_environment true org.eclipse.cdt.make.core.autoBuildTarget all org.eclipse.cdt.make.core.buildArguments org.eclipse.cdt.make.core.buildCommand make org.eclipse.cdt.make.core.buildLocation ${workspace_loc:/SOAPsnpZ/Debug} org.eclipse.cdt.make.core.cleanBuildTarget clean org.eclipse.cdt.make.core.contents org.eclipse.cdt.make.core.activeConfigSettings org.eclipse.cdt.make.core.enableAutoBuild false org.eclipse.cdt.make.core.enableCleanBuild true org.eclipse.cdt.make.core.enableFullBuild true org.eclipse.cdt.make.core.fullBuildTarget all org.eclipse.cdt.make.core.stopOnError true org.eclipse.cdt.make.core.useDefaultBuildCmd true org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder org.eclipse.cdt.core.cnature org.eclipse.cdt.managedbuilder.core.ScannerConfigNature org.eclipse.cdt.core.ccnature org.eclipse.cdt.managedbuilder.core.managedBuildNature SOAPsnpZ/.cproject0000644000105300010600000013430611206446367014171 0ustar yuchangyuchang SOAPsnpZ/call_genotype.cc0000644000105300010600000005342611206446367015516 0ustar yuchangyuchang#include "soap_snp.h" #include int Call_win::initialize(ubit64_t start) { std::string::size_type i; for(i=0; i != read_len + win_size ; i++) { sites[i].pos = i+start; } return 1; } int Call_win::deep_init(ubit64_t start) { int i; for(i=0; i != read_len + win_size ; i++) { sites[i].pos = i+start; sites[i].ori = 0xFF; sites[i].depth = 0; sites[i].repeat_time = 0; sites[i].dep_uni = 0; memset(sites[i].count_uni,0,sizeof(int)*4); memset(sites[i].q_sum,0,sizeof(int)*4); memset(sites[i].base_info,0,sizeof(small_int)*4*2*64*256); memset(sites[i].count_all,0,sizeof(int)*4); } return 1; } int Call_win::recycle() { std::string::size_type i; for(i=0; i != read_len ; i++) { sites[i].pos = sites[i+win_size].pos; sites[i].ori = sites[i+win_size].ori; sites[i].depth = sites[i+win_size].depth; sites[i].repeat_time = sites[i+win_size].repeat_time; sites[i].dep_uni = sites[i+win_size].dep_uni; memcpy(sites[i].base_info, sites[i+win_size].base_info, sizeof(small_int)*4*2*64*256); // 4 types of bases, 2 strands, max quality score is 64, and max read length 256 memcpy(sites[i].count_uni, sites[i+win_size].count_uni, sizeof(int)*4); memcpy(sites[i].q_sum, sites[i+win_size].q_sum, sizeof(int)*4); memcpy(sites[i].count_all, sites[i+win_size].count_all, sizeof(int)*4); } for(i=read_len; i != read_len+win_size; i++) { sites[i].ori = 0xFF; sites[i].pos = sites[i-1].pos+1; sites[i].depth = 0; sites[i].repeat_time = 0; sites[i].dep_uni = 0; memset(sites[i].count_uni,0,sizeof(int)*4); memset(sites[i].q_sum,0,sizeof(int)*4); memset(sites[i].base_info,0,sizeof(small_int)*4*2*64*256); memset(sites[i].count_all,0,sizeof(int)*4); } return 1; } int Call_win::call_cns(Chr_name call_name, Chr_info* call_chr, ubit64_t call_length, Prob_matrix * mat, Parameter * para, std::ofstream & consensus, std::ofstream & baseinfo) { std::string::size_type coord; small_int k; ubit64_t o_base, strand; char allele1, allele2, genotype, type, type1/*best genotype*/, type2/*suboptimal genotype*/, base1, base2, base3; int i, q_score, q_adjusted, qual1, qual2, qual3, q_cns, all_count1, all_count2, all_count3; int global_dep_count, *pcr_dep_count; pcr_dep_count = new int [para->read_length*2]; double rank_sum_test_value, binomial_test_value; bool is_out; double * real_p_prior = new double [16]; double * likelihoods = new double [10]; memset(likelihoods, 0, sizeof(double)*10); //std::cerr<<"Call length="<region_only) { if (NULL== call_chr->get_region() ) { break; } else if (! call_chr->is_in_region(sites[j].pos)) { continue; } else { ; } } sites[j].ori = (call_chr->get_bin_base(sites[j].pos))&0xF; if( ((sites[j].ori&4) !=0)/*an N*/ && sites[j].depth == 0) { // CNS text format: // ChrID\tPos\tRef\tCns\tQual\tBase1\tAvgQ1\tCountUni1\tCountAll1\tBase2\tAvgQ2\tCountUni2\tCountAll2\tDepth\tRank_sum\tCopyNum\tSNPstauts\n" if(!para->glf_format && ! para->is_snp_only) { consensus<glf_format) { memset(likelihoods, 0, sizeof(double)*10); consensus.write(reinterpret_cast(likelihoods), sizeof(double)*10); consensus<= qual1) { base3 = base2; qual3 = qual2; base2 = base1; qual2 = qual1; base1 = i; qual1 = sites[j].q_sum[i]; } else if (sites[j].q_sum[i]>=qual2) { base3 = base2; qual3 = qual2; base2 = i; qual2 = sites[j].q_sum[i]; } else if (sites[j].q_sum[i]>=qual3) { base3 = i; qual3 = sites[j].q_sum[i]; } else { ; } } if(qual1 == 0) { // Adjust the best base so that things won't look ugly if the pos is not covered base1 = (sites[j].ori&7); } else if(qual2 ==0 && base1 != (sites[j].ori&7)) { base2 = (sites[j].ori&7); } else { ; } } else { // This position is covered by all repeats for(i=0;i!=4;i++) { if(sites[j].count_all[i] >= all_count1) { base3 = base2; all_count3 = all_count2; base2 = base1; all_count2 = all_count1; base1 = i; all_count1 = sites[j].count_all[i]; } else if (sites[j].count_all[i]>=all_count2) { base3 = base2; all_count3 = all_count2; base2 = i; all_count2 = sites[j].count_all[i]; } else if (sites[j].count_all[i]>=all_count3) { base3 = i; all_count3 = sites[j].count_all[i]; } else { ; } } if(all_count1 ==0) { base1 = (sites[j].ori&7); } else if(all_count2 ==0 && base1 != (sites[j].ori&7)) { base2 = (sites[j].ori&7); } else { ; } } // Calculate likelihood for(genotype=0;genotype!=16;genotype++){ mat->type_likely[genotype] = 0.0; } for(o_base=0;o_base!=4;o_base++) { //cerr<read_length); for(q_score=para->q_max-para->q_min; q_score != -1; q_score--) { for(coord=0; coord != para->read_length; coord++) { for(strand=0; strand!=2; strand++) { for(k=0; k!=sites[j].base_info[o_base<<15|strand<<14|q_score<<8|coord];k++) { if(pcr_dep_count[strand*para->read_length+coord]==0) { global_dep_count += 1; //if(sites[j].pos == 250948) { // cerr<<'g'<p_matrix[ ((ubit64_t)q_adjusted<<12) | (coord <<4) | (allele1<<2) | o_base], mat->p_matrix[ ((ubit64_t)q_adjusted<<12) | (coord <<4) | (allele2<<2) | o_base], mat->type_likely[allele1<<2|allele2]); //} } pcr_dep_count[strand*para->read_length+coord] += 1; //if(sites[j].pos == 250948) { // cerr<<'p'<read_length+coord]<<'\t';//fprintf(stderr, "Now:%c\t\t%le\t%le\t%le\n", abbv[allele1<<2|allele2], mat->p_matrix[ ((ubit64_t)q_adjusted<<12) | (coord <<4) | (allele1<<2) | o_base], mat->p_matrix[ ((ubit64_t)q_adjusted<<12) | (coord <<4) | (allele2<<2) | o_base], mat->type_likely[allele1<<2|allele2]); //} q_adjusted = int( pow(10, (log10(q_score) +(pcr_dep_count[strand*para->read_length+coord]-1)*para->pcr_dependency +global_dep_count*para->global_dependency)) +0.5); if(q_adjusted < 1) { q_adjusted = 1; } for(allele1 = 0;allele1 != 4;allele1++ ) { for(allele2 = allele1; allele2 != 4; allele2++) { mat->type_likely[allele1<<2|allele2] += log10(0.5*mat->p_matrix[ ((ubit64_t)q_adjusted<<12) | (coord <<4) | (allele1<<2) | o_base] +0.5*mat->p_matrix[((ubit64_t)q_adjusted<<12) | (coord <<4) | (allele2<<2) | o_base]); //if(sites[j].pos == 52100) { // cerr<<"Now:"<p_matrix[ ((ubit64_t)q_adjusted<<12) | (coord <<4) | (allele1<<2) | o_base]<<'\t'<p_matrix[ ((ubit64_t)q_adjusted<<12) | (coord <<4) | (allele2<<2) | o_base]<<'\t'<type_likely[allele1<<2|allele2]<type_likely[0]<<'\t'<type_likely[5]<<'\t'<type_likely[10]<<'\t'<type_likely[15]<p_matrix[ ((ubit64_t)q_adjusted<<12) | (coord <<4) | (allele1<<2) | o_base], mat->p_matrix[ ((ubit64_t)q_adjusted<<12) | (coord <<4) | (allele2<<2) | o_base], mat->type_likely[allele1<<2|allele2]); //} } } } } } if(para->glf_format) { for(int i=0; i!=10; i++) { consensus.write(reinterpret_cast(&mat->type_likely[glf_type_code[i]]), sizeof(double)); } consensus<p_prior[((ubit64_t)sites[j].ori&0x7)<<4], sizeof(double)*16); if ( (sites[j].ori & 0x8) && para->refine_mode) { // a dbSNP snp_p_prior_gen(real_p_prior, call_chr->find_snp(sites[j].pos), para, sites[j].ori); } memset(mat->type_prob,0,sizeof(rate_t)*17); type2=type1=16; for (allele1=0; allele1!=4; allele1++) { for (allele2=allele1; allele2!=4; allele2++) { genotype = allele1<<2|allele2; if (para->is_monoploid && allele1 != allele2) { continue; } mat->type_prob[genotype] = mat->type_likely[genotype] + log10(real_p_prior[genotype]) ; if (mat->type_prob[genotype] >= mat->type_prob[type1] || type1 == 16) { type2 = type1; type1 = genotype; } else if (mat->type_prob[genotype] >= mat->type_prob[type2] || type2 ==16) { type2 = genotype; } else { ; } } } is_out = true; // Check if the position needs to be output, useful in snp-only mode if (para->rank_sum_mode) { rank_sum_test_value = rank_test(sites[j], type1, mat->p_rank, para); } else { rank_sum_test_value = 1.0; } if(rank_sum_test_value==0.0) { // avoid double genotype overflow q_cns = 0; } else { q_cns = (int)(10*(mat->type_prob[type1]-mat->type_prob[type2])+10*log10(rank_sum_test_value)); } if ( (type1&3) == ((type1>>2)&3)) { // Called Homozygous if (qual1>0 && base1 != (type1&3)) { //Wired: best base is not the consensus! q_cns = 0; } else if (/*qual2>0 &&*/ q_cns > qual1-qual2) { // Should not bigger than this q_cns = qual1-qual2; } else { ; } } else { // Called Heterozygous if(sites[j].q_sum[base1]>0 && sites[j].q_sum[base2]>0 && type1 == (base1 qual2-qual3) { q_cns = qual2-qual3; } } else { // Ok, wired things happened q_cns = 0; } } if(q_cns>99) { q_cns = 99; } if (q_cns<0) { q_cns = 0; } if(! para->glf_format) { // ChrID\tPos\tRef\tCns\tQual\tBase1\tAvgQ1\tCountUni1\tCountAll1\tBase2\tAvgQ2\tCountUni2\tCountAll2\tDepth\tRank_sum\tCopyNum\tSNPstauts\n" if(! para->is_snp_only || (abbv[type1] != "ACTGNNNN"[(sites[j].ori&0x7)] && sites[j].depth > 0)) { if(base1<4 && base2<4) { consensus<::iterator current_chr, prev_chr; current_chr = prev_chr = genome->chromosomes.end(); int coord, sub; int last_start(0); bool recycled(false); for(std::string line; getline(alignment, line);) { std::istringstream s(line); if( s>> soap ) { //cerr<<"A"<chromosomes.end() || current_chr->first != soap.get_chr_name()) { if(current_chr != genome->chromosomes.end() ) { recycled = false; while(current_chr->second->length() > sites[win_size-1].pos) { if (!para->region_only || current_chr->second->is_in_region_win(last_start)) { //cerr<<"at"< sites[win_size-1].pos) { initialize((last_start/win_size)*win_size); } call_cns(current_chr->first, current_chr->second, win_size, mat, para, consensus, baseinfo); last_start = sites[win_size-1].pos; recycled = false; } if (!para->region_only) { //cerr<<"recycled"<(sites[win_size-1].pos)) { cerr<<"Unexpected "<"<<(sites[win_size-1].pos)<"<second->is_in_region_win(sites[win_size].pos)) { recycle(); } else { deep_init(sites[win_size].pos); } } recycled = true; last_start = sites[win_size-1].pos; } else { assert((last_start+1)%win_size==0); last_start += win_size; } } // The last window if(last_start > sites[win_size-1].pos) { initialize((last_start/win_size)*win_size); } call_cns(current_chr->first, current_chr->second, current_chr->second->length()%win_size, mat, para, consensus, baseinfo); } current_chr = genome->chromosomes.find(soap.get_chr_name()); initialize(0); last_start = 0; cerr<<"Processing "<first<=current_chr->second->length()) { continue; } if (para->region_only && (current_chr->second->get_region() == NULL || !current_chr->second->is_in_region(soap.get_pos()))) { continue; } if(soap.get_pos() < last_start) { cerr<<"Errors in sorting:"< last_start/win_size ) { if (!para->region_only || current_chr->second->is_in_region_win(last_start)) { //cerr<<"at"< sites[win_size-1].pos) { initialize((last_start/win_size)*win_size); } call_cns(current_chr->first, current_chr->second, win_size, mat, para, consensus, baseinfo); last_start = sites[win_size-1].pos; recycled = false; } if (!para->region_only) { //cerr<<"recycled"<(sites[win_size-1].pos)) { cerr<<"Unexpected "<"<<(sites[win_size-1].pos)<"<second->is_in_region_win(sites[win_size].pos)) { recycle(); } else { deep_init(sites[win_size].pos); } } recycled = true; last_start = sites[win_size-1].pos; } else { assert((last_start+1)%win_size==0); last_start += win_size; } //if ((last_start+1)/win_size==1000) { // cerr<<"Called "<q_min || sites[sub].dep_uni >= 0xFF) { // An N, low quality or meaningless huge depth continue; } if(soap.get_hit() == 1) { //exit((fprintf(stderr, "Wo Cao!\n"))); sites[sub].dep_uni += 1; // Update the covering info: 4x2x64x64 matrix, base x strand x q_score x read_pos, 2-1-6-6 bits for each if(soap.is_fwd()) { // Binary strand: 0 for plus and 1 for minus sites[sub].base_info[(((ubit64_t)(soap.get_base(coord)&0x6)|0))<<14 | ((ubit64_t)(soap.get_qual(coord)-para->q_min))<<8 | coord ] += 1; } else { sites[sub].base_info[(((ubit64_t)(soap.get_base(coord)&0x6)|1))<<14 | ((ubit64_t)(soap.get_qual(coord)-para->q_min))<<8 | (soap.get_read_len()-1-coord) ] += 1; } sites[sub].count_uni[(soap.get_base(coord)>>1)&3] += 1; sites[sub].q_sum[(soap.get_base(coord)>>1)&3] += (soap.get_qual(coord)-para->q_min); } else { ;// Repeats } sites[sub].count_all[(soap.get_base(coord)>>1)&3] += 1; } } } //The unprocessed tail of chromosome recycled = false; while(current_chr->second->length() > sites[win_size-1].pos) { if (!para->region_only || current_chr->second->is_in_region_win(last_start)) { //cerr<<"at"< sites[win_size-1].pos) { initialize((last_start/win_size)*win_size); } call_cns(current_chr->first, current_chr->second, win_size, mat, para, consensus, baseinfo); last_start = sites[win_size-1].pos; recycled = false; } if (!para->region_only) { //cerr<<"recycled"<(sites[win_size-1].pos)) { cerr<<"Unexpected "<"<<(sites[win_size-1].pos)<"<second->is_in_region_win(sites[win_size].pos)) { recycle(); } else { deep_init(sites[win_size].pos); } } recycled = true; last_start = sites[win_size-1].pos; } else { assert((last_start+1)%win_size==0); last_start += win_size; } } // The last window if(last_start > sites[win_size-1].pos) { initialize((last_start/win_size)*win_size); } call_cns(current_chr->first, current_chr->second, current_chr->second->length()%win_size, mat, para, consensus, baseinfo); alignment.close(); consensus.close(); baseinfo.close(); return 1; } SOAPsnpZ/chromosome.cc0000644000105300010600000001370311206446367015036 0ustar yuchangyuchang#include "soap_snp.h" bool Genome::add_chr(Chr_name & name) { Chr_info * new_chr = new Chr_info; pair::iterator, bool> insert_pair; insert_pair=chromosomes.insert(pair(name,new_chr)); return insert_pair.second; } Genome::~Genome(){ for( map::iterator iter=chromosomes.begin(); iter!= chromosomes.end(); iter++ ){ ; } } Chr_info::Chr_info(const Chr_info & other) { dbsnp = other.dbsnp; len = other.len; if (len%capacity==0) { bin_seq = new ubit64_t [len/capacity]; memcpy(bin_seq, other.bin_seq, sizeof(ubit64_t)*len/capacity); } else { bin_seq = new ubit64_t [1+len/capacity]; memcpy(bin_seq, other.bin_seq, sizeof(ubit64_t)*len/capacity); } } int Chr_info::binarize(std::string & seq) { len = seq.length(); //cerr<>1)&7)<<(i%capacity*4)); } return 1; } int Chr_info::insert_snp(std::string::size_type pos, Snp_info & snp_form) { Snp_info * new_snp = new Snp_info; *new_snp = snp_form; pair::iterator, bool> insert_pair; insert_pair = dbsnp.insert(pair(pos,new_snp)); if(insert_pair.second) { // Successful insertion // Modify the binary sequence! Mark SNPs bin_seq[pos/capacity] |= (1ULL<<(pos%capacity*4+3)); } else { cerr<<"Warning: Snp insertion failed\t"<= len) { start = len; } if(end<0) { end = 0; } else if (end >= len) { end = len; } if (start > end) { cerr<<"Invalid region: "<1) { memset(region_mask+start/64+1, 0xFF, sizeof(ubit64_t)*(end/64-start/64-1)); } } // Window mask start /= global_win_size; end /= global_win_size; //cerr<1) { memset(region_win_mask+start/64+1, 0xFF, sizeof(ubit64_t)*(end/64-start/64-1)); } } return 1; } int Chr_info::region_mask_ini(){ //Specific mask if(len%64==0) { region_mask = new ubit64_t [len/64]; memset(region_mask, 0, sizeof(ubit64_t)*(len/64)); } else { region_mask = new ubit64_t [len/64+1]; memset(region_mask, 0, sizeof(ubit64_t)*(len/64+1)); } //Window mask int win_len = len/global_win_size +1; if(win_len%64==0) { region_win_mask = new ubit64_t [win_len/64]; memset(region_win_mask, 0, sizeof(ubit64_t)*(win_len/64)); } else { region_win_mask = new ubit64_t [win_len/64+1]; memset(region_win_mask, 0, sizeof(ubit64_t)*(win_len/64+1)); } return 1; } int Genome::read_region(std::ifstream & region, Parameter * para) { Chr_name current_name(""), prev_name(""); int start, end; map::iterator chr_iter; for(std::string buff;getline(region,buff);) { std::istringstream s(buff); if(s>>current_name>>start>>end) { if(current_name != prev_name) { chr_iter = chromosomes.find(current_name); if(chr_iter == chromosomes.end()) { cerr<<"Unexpected Chromosome:"<second->get_region()) { chr_iter->second->region_mask_ini(); } } chr_iter->second->set_region(start-para->read_length, end-1); prev_name = current_name; } else { cerr<<"Wrong format in target region file"<::iterator chr_iter; for(std::string buff;getline(fasta,buff);) { if('>' == buff[0]) { // Fasta id // Deal with previous chromosome if( chromosomes.find(current_name) != chromosomes.end()) { chr_iter = chromosomes.find(current_name); chr_iter->second->binarize(seq); } // Insert new chromosome std::string::size_type i; for(i=1;!isspace(buff[i]) && i != buff.length();i++) { ; } Chr_name new_chr_name(buff,1,i-1); if(! add_chr(new_chr_name)) { std::cerr<<"Insert Chromosome "<second->binarize(seq); } if( known_snp ) { Chr_name current_name; Snp_info snp_form; std::string::size_type pos; for(std::string buff;getline(known_snp, buff);) { // Format: Chr\tPos\thapmap?\tvalidated?\tis_indel?\tA\tC\tT\tG\trsID\n std::istringstream s(buff); s>>current_name>>pos; s>>snp_form; if( chromosomes.find(current_name) != chromosomes.end()) { // The SNP is located on an valid chromosme pos -= 1; // Coordinates starts from 0 (chromosomes.find(current_name)->second)->insert_snp(pos, snp_form); } } } } SOAPsnpZ/main.cc0000644000105300010600000002161111206446367013604 0ustar yuchangyuchang#include "soap_snp.h" #include using namespace std; int usage() { cerr<<"SoapSNP"< Input SORTED Soap Result"< Reference Sequence in fasta format"< Output consensus file"< ASCII chracter standing for quality==0 [@]"< Global Error Dependency Coefficient, 0.0(complete dependent)~1.0(complete independent)[0.9]"< PCR Error Dependency Coefficient, 0.0(complete dependent)~1.0(complete independent)[0.5]"< novel altHOM prior probability [0.0005]"< novel HET prior probability [0.0010]"< Pre-formated dbSNP information"< Validated HET prior, if no allele frequency known [0.1]"< Validated altHOM prior, if no allele frequency known[0.05]"< Unvalidated HET prior, if no allele frequency known [0.02]"< Unvalidated altHOM rate, if no allele frequency known[0.01]"< Output the quality calibration matrix; the matrix can be reused with -I if you rerun the program"< Input previous quality calibration matrix. It cannot be used simutaneously with -M"< maximum length of read [45]"< maximum FASTQ quality score [40]"< Output format. 0: Text; 1: GLFv2; 2: GPFv2.[0]"< Extra headers EXCEPT CHROMOSOME FIELD specified in GLFv2 output. Format is \"TypeName1:DataName1:TypeName2:DataName2\"[""]"< Only call consensus on regions specified in FILE. Format: ChrName\\tStart\\tEnd."< Output summary of consensus"<q_min = optarg[0]; if(para->q_min == 33) { clog<<"Standard Fastq System Set"<q_min == 64) { clog<<"Illumina Fastq System Set"<q_max = para->q_min + 40; break; } case 'g': { para->global_dependency= log10(atof(optarg)); break; } case 'p': { para->pcr_dependency= log10(atof(optarg)); break; } case 'r': { para->althom_novel_r = atof(optarg); break; } case 'e': { para->het_novel_r=atof(optarg); break; } case 't': { para->transition_dominant=true; break; } case 's': { // Optional: A pre-formated dbSNP table files.dbsnp.clear(); files.dbsnp.open(optarg); if( ! files.ref_seq) { cerr<<"No such file or directory:"<refine_mode = true; break; } case 'a': { para->althom_val_r=atof(optarg); break; } case 'b': { para->het_val_r=atof(optarg); break; } case 'j': { para->althom_unval_r=atof(optarg); break; } case 'k': { para->het_unval_r=atof(optarg); break; } case 'u': { para->rank_sum_mode = true; break; } case 'n': { para->binom_mode = true; break; } case 'm': { para->is_monoploid=1; break; } case 'q': { para->is_snp_only=1; break; } case 'M': { files.matrix_file.close(); files.matrix_file.clear(); // Output the calibration matrix files.matrix_file.open(optarg, fstream::out); if( ! files.matrix_file) { cerr<<"Cannot creat file :"<read_length = atoi(optarg); break; } case 'Q': { para->q_max = optarg[0]; if(para->q_max < para->q_min) { cerr<< "FASTQ quality character error: Q_MAX > Q_MIN" <glf_format = atoi(optarg); break; } case 'E': { para->glf_header = optarg; break; } case 'T': { files.region.clear(); files.region.open(optarg); files.region.clear(); para->region_only = true; break; } case 'h':readme();break; case '?':usage();break; default: cerr<<"Unknown error in command line parameters"<glf_format ) { // Normal SOAPsnp tab-delimited text format files.consensus.clear(); files.consensus.open(consensus_name.c_str()); if( ! files.consensus ) { cerr<<"Cannot creat file:" <region_only && files.region) { genome->read_region(files.region, para); clog<<"Read target region done."<matrix_gen(files.soap_result, para, genome); if (files.matrix_file) { mat->matrix_write(files.matrix_file, para); } } else { mat->matrix_read(files.matrix_file, para); } files.matrix_file.close(); clog<<"Correction Matrix Done!"<prior_gen(para); mat->rank_table_gen(); Call_win info(para->read_length); info.initialize(0); //Call the consensus files.soap_result.close(); files.soap_result.clear(); files.soap_result.open(alignment_name.c_str()); files.soap_result.clear(); info.soap2cns(files.soap_result, files.consensus, files.baseinfo, genome, mat, para); files.soap_result.close(); files.consensus.close(); cerr<<"Consensus Done!"<::iterator current_chr; current_chr = genome->chromosomes.end(); ubit64_t ref(0); std::string::size_type coord; for(std::string line; getline(alignment, line);) { std::istringstream s(line); if( s>> soap ) { if(soap.get_pos() < 0) { continue; } //cerr<chromosomes.end() || current_chr->first != soap.get_chr_name()) { current_chr = genome->chromosomes.find(soap.get_chr_name()); if(current_chr == genome->chromosomes.end()) { for(map::iterator test = genome->chromosomes.begin();test != genome->chromosomes.end();test++) { cerr<<'!'<<(test->first)<<'!'<=current_chr->second->length()) { continue; } if (soap.is_unique()) { for(coord = 0; coord != soap.get_read_len(); coord++) { if (soap.is_N(coord)) { ; } else { if(! (soap.get_pos()+coordsecond->length())) { cerr<first<<" FASTA Length: "<second->length()<second->get_bin_base(soap.get_pos()+coord); if ( (ref&12) !=0 ) { // This is an N on reference or a dbSNP which should be excluded from calibration ; } else { if(soap.is_fwd()) { // forward strand count_matrix[(((ubit64_t)soap.get_qual(coord))<<12) | (coord<<4) | ((ref&0x3)<<2) | (soap.get_base(coord)>>1)&3] += 1; } else { // reverse strand count_matrix[(((ubit64_t)soap.get_qual(coord))<<12) | ((soap.get_read_len()-1-coord)<<4) | ((ref&0x3)<<2) | (soap.get_base(coord)>>1)&3] += 1; } } } } } } } ubit64_t o_base/*o_based base*/, t_base/*theorecical(supposed) base*/, type, sum[4], same_qual_count_by_type[16], same_qual_count_by_t_base[4], same_qual_count_total, same_qual_count_mismatch; char q_char/*fastq quality char*/; const ubit64_t sta_pow=10; // minimum number to say statistically powerful for(q_char=para->q_min; q_char<=para->q_max ;q_char++) { memset(same_qual_count_by_type, 0, sizeof(ubit64_t)*16); memset(same_qual_count_by_t_base, 0, sizeof(ubit64_t)*4); same_qual_count_total = 0; same_qual_count_mismatch = 0; for(coord=0; coord != para->read_length ; coord++) { for(type=0;type!=16;type++) { // If the sample is small, then we will not consider the effect of read cycle. same_qual_count_by_type[type] += count_matrix[ ((ubit64_t)q_char<<12) | coord <<4 | type]; same_qual_count_by_t_base[(type>>2)&3] += count_matrix[ ((ubit64_t)q_char<<12) | coord <<4 | type]; same_qual_count_total += count_matrix[ ((ubit64_t)q_char<<12) | coord <<4 | type]; //cerr<<(int)type<<'\t'<read_length ; coord++) { //cerr<<(q_char)<<'\t'<>2)&3] += count_matrix[ ((ubit64_t)q_char<<12) | (coord <<4) | type]; // (type>>2)&3: the ref base //cerr< sta_pow) { // Statistically powerful p_matrix [ ((ubit64_t)(q_char-para->q_min)<<12) | (coord <<4) | (t_base<<2) | o_base] = ((double)count_matrix[ ((ubit64_t)q_char<<12) | (coord <<4) | (t_base<<2) | o_base]) / sum[t_base]; } else if (same_qual_count_by_type[t_base<<2|o_base] > sta_pow) { // Smaller sample, given up effect from read cycle p_matrix [ ((ubit64_t)(q_char-para->q_min)<<12) | (coord <<4) | (t_base<<2) | o_base] = ((double)same_qual_count_by_type[t_base<<2|o_base]) / same_qual_count_by_t_base[t_base]; } else if (same_qual_count_total > 0){ // Too small sample, given up effect of mismatch types if (o_base == t_base) { p_matrix [ ((ubit64_t)(q_char-para->q_min)<<12) | (coord <<4) | (t_base<<2) | o_base] = ((double)(same_qual_count_total-same_qual_count_mismatch))/same_qual_count_total; } else { p_matrix [ ((ubit64_t)(q_char-para->q_min)<<12) | (coord <<4) | (t_base<<2) | o_base] = ((double)same_qual_count_mismatch)/same_qual_count_total; } } else { ; } // For these cases like: // Ref: G o_base: G x10 Ax5. When calculate the probability of this allele to be A, // If there's no A in reference gives observation of G, then the probability will be zero, // And therefore exclude the possibility of this pos to have an A // These cases should be avoid when the dataset is large enough // If no base with certain quality is o_based, it also doesn't matter if( (p_matrix [ ((ubit64_t)(q_char-para->q_min)<<12) | (coord <<4) | (t_base<<2) | o_base]==0) || p_matrix [ ((ubit64_t)(q_char-para->q_min)<<12) | (coord <<4) | (t_base<<2) | o_base] ==1) { if (o_base == t_base) { p_matrix [ ((ubit64_t)(q_char-para->q_min)<<12) | (coord <<4) | (t_base<<2) | o_base] = (1-pow(10, -((q_char-para->q_min)/10.0))); if(p_matrix [ ((ubit64_t)(q_char-para->q_min)<<12) | (coord <<4) | (t_base<<2) | o_base]<0.25) { p_matrix [ ((ubit64_t)(q_char-para->q_min)<<12) | (coord <<4) | (t_base<<2) | o_base] = 0.25; } } else { p_matrix [ ((ubit64_t)(q_char-para->q_min)<<12) | (coord <<4) | (t_base<<2) | o_base] = (pow(10, -((q_char-para->q_min)/10.0))/3); if(p_matrix [ ((ubit64_t)(q_char-para->q_min)<<12) | (coord <<4) | (t_base<<2) | o_base]>0.25) { p_matrix [ ((ubit64_t)(q_char-para->q_min)<<12) | (coord <<4) | (t_base<<2) | o_base] = 0.25; } } } } } } //cerr<<'\t'<q_max-para->q_min+1)<<12], 0, 256*256*4*4 - (para->q_max-para->q_min+1)*256*4*4); // Note: from now on, the first 8 bit of p_matrix is its quality score, not the FASTQ char return 1; } int Prob_matrix::matrix_read(std::fstream &mat_in, Parameter * para) { int q_char, type; std::string::size_type coord; for(std::string line; getline(mat_in, line);) { std::istringstream s(line); s>>q_char>>coord; for(type=0;type!=16;type++) { s>>p_matrix [ ((ubit64_t)q_char<<12) | (coord <<4) | type]; //cerr<q_min; q_char <= para->q_max; q_char++ ) { for( std::string::size_type coord=0; coord != para->read_length; coord++) { mat_out<<((ubit64_t)q_char-para->q_min)<<'\t'<q_min)<<12) | (coord <<4) | type]; } mat_out<6.0 || z<-6.0) { return 0.0; } else { double b1 = 0.31938153; double b2 = -0.356563782; double b3 = 1.781477937; double b4 = -1.821255978; double b5 = 1.330274429; double p = 0.2316419; double c2 = 0.39894228; double a = fabs(z); double t = 1.0/(1.0+a*p); double b = c2*exp((-z)*(z/2.0)); double n = ((((b5*t+b4)*t+b3)*t+b2)*t+b1)*t; n = 1.0 - b*n; if (z < 0.0) n = 1.0 - n; return n>0.5?1-n:n; } } SOAPsnpZ/prior.cc0000644000105300010600000000662611206446370014016 0ustar yuchangyuchang#include "soap_snp.h" int Prob_matrix::prior_gen(Parameter * para) { char t_base, allele1, allele2; // Note, the above parameter should be changed to a more reasonable one for(t_base=0;t_base!=4;t_base++) { for(allele1=0;allele1!=4;allele1++) { for(allele2=allele1;allele2!=4;allele2++) { if(allele1 == t_base && allele2 == t_base) { // refHOM p_prior[t_base<<4|allele1<<2|allele2] = 1; } else if (allele1 == t_base || allele2 == t_base) { // refHET: 1 ref 1 alt p_prior[t_base<<4|allele1<<2|allele2] = para->het_novel_r; } else if (allele1 == allele2) { // altHOM p_prior[t_base<<4|allele1<<2|allele2] = para->althom_novel_r; } else { // altHET: 2 diff alt base p_prior[t_base<<4|allele1<<2|allele2] = para->het_novel_r * para->althom_novel_r; } if( para->transition_dominant && ((allele1^t_base) == 0x3 || (allele2^t_base) == 0x3)) { // transition p_prior[t_base<<4|allele1<<2|allele2] *= 4; } //std::cerr<<"ACTG"[t_base]<<"\t"<<"ACTG"[allele1]<<"ACTG"[allele2]<<"\t"<het_novel_r)) * 0.25 *0.25; p_prior[0x5<<4|allele1<<2|allele2] = (allele1==allele2? 1: (2*para->het_novel_r)) * 0.25 *0.25; p_prior[0x6<<4|allele1<<2|allele2] = (allele1==allele2? 1: (2*para->het_novel_r)) * 0.25 *0.25; p_prior[0x7<<4|allele1<<2|allele2] = (allele1==allele2? 1: (2*para->het_novel_r)) * 0.25 *0.25; } } return 1; } int Call_win::snp_p_prior_gen(double * real_p_prior, Snp_info* snp, Parameter * para, char ref) { if (snp->is_indel()) { return 0; } char base, allele1, allele2; int allele_count; allele_count = 0; for (base=0; base != 4; base ++) { if(snp->get_freq(base)>0) { // The base is found in dbSNP allele_count += 1; } } if(allele_count <= 1) { // Should never occur cerr<<"Previous Extract SNP error."<is_hapmap()) { if(snp->get_freq(allele1)>0 && snp->get_freq(allele2)>0) { // Here the frequency is just a tag to indicate SNP alleles in non-HapMap sites if(allele1 == allele2 && allele1 == t_base) { // refHOM real_p_prior[allele1<<2|allele2] = 1; } else if (allele1 == t_base || allele2 == t_base) { // refHET: 1 ref 1 alt real_p_prior[allele1<<2|allele2] = snp->is_validated()?para->het_val_r:para->het_unval_r; } else if (allele1 == allele2) { real_p_prior[allele1<<2|allele2] = snp->is_validated()?para->althom_val_r:para->althom_unval_r; } else { // altHET: 2 diff alt base real_p_prior[allele1<<2|allele2] = snp->is_validated()?para->het_val_r:para->het_unval_r; } } } else { // Real HapMap Sites if(snp->get_freq(allele1)>0 && snp->get_freq(allele2)>0) { real_p_prior[allele1<<2|allele2] = (allele1==allele2?1:(2*para->het_val_r))*snp->get_freq(allele1)*snp->get_freq(allele2); } } //cerr<<"ACTG"[t_base]<<"\t"<<"ACTG"[allele1]<<"ACTG"[allele2]<<"\t"<=N && n1>0) ? rank_sum[((N-1)<<17)|((n1-1)<<11)|(T1-N)]:0); // Here, the p_rank is not cumulative p_rank[(N<<17)|(n1<<11)|T1] = rank_sum[N<<17|n1<<11|T1] / (fact[N]/(fact[n1]*fact[N-n1])); //cerr<fabs(u2)?u1:u2); } double Call_win::table_test(double *p_rank, int n1, int n2, double T1, double T2) { if(n1<=n2) { return p_rank[(n1+n2)<<17|n1<<11|(int)(T1)]+(T1-(int)T1)*(p_rank[(n1+n2)<<16|n1<<11|(int)(T1+1)]-p_rank[(n1+n2)<<17|n1<<11|(int)(T1)]); } else { return p_rank[(n1+n2)<<17|n2<<11|(int)(T2)]+(T2-(int)T2)*(p_rank[(n1+n2)<<16|n2<<11|(int)(T2+1)]-p_rank[(n1+n2)<<17|n2<<11|(int)(T2)]); } } double Call_win::rank_test(Pos_info & info, char best_type, double * p_rank, Parameter * para) { if( (best_type&3) == ((best_type>>2)&3) ) { // HOM return 1.0; } if( info.count_uni[best_type&3]==0 || info.count_uni[(best_type>>2)&3]==0) { // HET with one allele... return 0.0; } //cerr<<"RankSum:"<q_max-para->q_min+1]; //memset(same_qual_count, 0, sizeof(int)*(para->q_max-para->q_min+1)); //double * rank_array= new double [para->q_max-para->q_min+1]; //memset(rank_array, 0, sizeof(double)*(para->q_max-para->q_min+1)); int *same_qual_count = new int [64]; double *rank_array = new double [64]; memset(same_qual_count,0,sizeof(int)*64); memset(rank_array,0,sizeof(double)*64); int rank(0); double T[4]={0.0, 0.0, 0.0, 0.0}; bool is_need[4] ={false,false,false,false}; is_need[(best_type&3)]=true; is_need[((best_type>>2)&3)]=true; std::string::size_type o_base, strand; int q_score, coord; for(o_base=0;o_base!=4;o_base++) { if(info.count_uni[o_base]==0 || !is_need[o_base]) continue; for(q_score=para->q_max-para->q_min;q_score>=0;q_score--) { for(coord=para->read_length-1;coord>=0;coord--) { for(strand=0;strand<2;strand++) { same_qual_count[q_score] += info.base_info[o_base<<15|strand<<14|q_score<<8|coord]; //if(info.pos==1256 && info.base_info[o_base<<13|strand<<12|q_score<<6|coord]!=0) { // cerr<q_max-para->q_min+1);q_score++) { rank_array[q_score]= rank+(1+same_qual_count[q_score])/2.0; rank += same_qual_count[q_score]; } for(o_base=0;o_base!=4;o_base++) { if(info.count_uni[o_base]==0 || !is_need[o_base]) continue; for(q_score=para->q_max-para->q_min;q_score>=0;q_score--) { for(coord=para->read_length-1;coord>=0;coord--) { for(strand=0;strand<2;strand++) { //cerr<<"ACTG"[o_base]<>2)&3], T[best_type&3], T[(best_type>>2)&3]); if (info.count_uni[best_type&3]+info.count_uni[(best_type>>2)&3]<64) { return table_test(p_rank, info.count_uni[best_type&3], info.count_uni[(best_type>>2)&3], T[best_type&3], T[(best_type>>2)&3]); } else { return normal_test(info.count_uni[best_type&3], info.count_uni[(best_type>>2)&3],T[best_type&3], T[(best_type>>2)&3]); } } SOAPsnpZ/soap_snp.h0000644000105300010600000002334611206446370014345 0ustar yuchangyuchang#ifndef SOAP_SNP_HH_ #define SOAP_SNP_HH_ #include #include #include #include #include #include #include #include #include #include #include #include typedef unsigned long long ubit64_t; typedef unsigned int ubit32_t; typedef double rate_t; typedef unsigned char small_int; using namespace std; const size_t capacity = sizeof(ubit64_t)*8/4; const char abbv[17]={'A','M','W','R','M','C','Y','S','W','Y','T','K','R','S','K','G','N'}; const ubit64_t glf_base_code[8]={1,2,8,4,15,15,15,15}; // A C T G const ubit64_t glf_type_code[10]={0,5,15,10,1,3,2,7,6,11};// AA,CC,GG,TT,AC,AG,AT,CG,CT,GT const int global_win_size = 1000; // Some global variables class Files { public: ifstream soap_result, ref_seq, dbsnp, region; ofstream consensus, baseinfo, o_region; fstream matrix_file; Files(){ soap_result.close(); ref_seq.close(); dbsnp.close(); consensus.close(); baseinfo.close(); matrix_file.close(); region.close(); o_region.close(); }; }; class Parameter { public: char q_min; // The char stands for 0 in fastq char q_max; // max quality score small_int read_length; // max read length bool is_monoploid; // Is it an monoploid? chrX,Y,M in man. bool is_snp_only; // Only output possible SNP sites? bool refine_mode; // Refine prior probability using dbSNP bool rank_sum_mode; // Use rank sum test to refine HET quality bool binom_mode; // Use binomial test to refine HET quality bool transition_dominant; // Consider transition/transversion ratio? int glf_format; // Generate Output in GLF format: New File Definitions! Since May 1, 2009 bool region_only; // Only report consensus in specified region std::string glf_header; // Header of GLF format rate_t althom_novel_r, het_novel_r; // Expected novel prior rate_t althom_val_r, het_val_r; // Expected Validated dbSNP prior rate_t althom_unval_r, het_unval_r; // Expected Unvalidated dbSNP prior rate_t global_dependency, pcr_dependency; // Error dependencies, 1 is NO dependency // Default onstruction Parameter(){ q_min = 64; q_max = 64+40; read_length = 45; is_monoploid = is_snp_only = refine_mode = rank_sum_mode = binom_mode = transition_dominant = region_only =false; glf_format = 0; glf_header = ""; althom_novel_r=0.0005, het_novel_r=0.0010; althom_val_r=0.05, het_val_r=0.10; althom_unval_r=0.01, het_unval_r=0.02; global_dependency= log10(0.9), pcr_dependency= log10(0.5); // In Log10 Scale }; }; class Soap_format { // Soap alignment result std::string read_id, read, qual, chr_name; int hit, read_len, position, mismatch; char ab, strand; public: Soap_format(){;}; friend std::istringstream & operator>>(std::istringstream & alignment, Soap_format & soap) { alignment>>soap.read_id>>soap.read>>soap.qual>>soap.hit>>soap.ab>>soap.read_len>>soap.strand>>soap.chr_name>>soap.position>>soap.mismatch; //cerr<200) { int indel_pos,indel_len; string temp(""); alignment>>indel_pos; indel_len = soap.mismatch-200; for(int i=0; i!=indel_len; i++) { temp = temp+'N'; } soap.read = soap.read.substr(0,indel_pos)+temp+soap.read.substr(indel_pos,soap.read_len-indel_pos); soap.qual = soap.qual.substr(0,indel_pos)+temp+soap.qual.substr(indel_pos,soap.read_len-indel_pos); //cerr<100) { int indel_pos,indel_len; alignment>>indel_pos; indel_len = soap.mismatch-100; soap.read = soap.read.substr(0,indel_pos) + soap.read.substr(indel_pos+indel_len, soap.read_len-indel_pos-indel_len); soap.qual = soap.qual.substr(0,indel_pos) + soap.qual.substr(indel_pos+indel_len, soap.read_len-indel_pos-indel_len); //cerr<>(std::istringstream & s, Snp_info & snp_form) { s>>snp_form.hapmap_site>>snp_form.validated>>snp_form.indel_site>>snp_form.freq[0]>>snp_form.freq[1]>>snp_form.freq[2]>>snp_form.freq[3]; return s; } Snp_info & operator=(Snp_info& other) { this->validated = other.validated; this->hapmap_site = other.hapmap_site; this->indel_site = other.indel_site; this->freq = new rate_t [4]; memcpy(this->freq, other.freq, sizeof(rate_t)*4); return *this; } bool is_validated(){ return validated; } bool is_hapmap(){ return hapmap_site; } bool is_indel(){ return indel_site; } rate_t get_freq(char bin_base_2bit) { return freq[bin_base_2bit]; } }; // Chromosome(Reference) information class Chr_info { ubit32_t len; ubit64_t* bin_seq; // Sequence in binary format ubit64_t* region_mask; ubit64_t* region_win_mask; // 4bits for one base: 1 bit dbSNPstatus, 1bit for N, followed two bit of base A: 00, C: 01, T: 10, G:11, // Every ubit64_t could store 16 bases map dbsnp; public: Chr_info(){ len = 0; bin_seq = NULL; region_mask = NULL; region_win_mask = NULL; }; Chr_info(const Chr_info & other); ~Chr_info(){ delete [] bin_seq; delete [] region_mask; delete [] region_win_mask; } ubit32_t length() { return len; } ubit64_t get_bin_base(std::string::size_type pos) { return (bin_seq[pos/capacity]>>(pos%capacity*4))&0xF; // All 4 bits } int binarize(std::string & seq); int insert_snp(std::string::size_type pos, Snp_info & new_snp); int region_mask_ini(); bool is_in_region(std::string::size_type pos) { return ((region_mask[pos/64]>>(63-pos%64))&1); } bool is_in_region_win(std::string::size_type pos) { pos /= global_win_size; // Calculate in which windows the site is //cerr<>(63-pos%64))&1); } int set_region(int start, int end); Snp_info * find_snp(ubit64_t pos) { return dbsnp.find(pos)->second; } ubit64_t * get_region() { return region_mask; } }; typedef std::string Chr_name; class Genome { public: map chromosomes; Genome(ifstream & fasta, ifstream & known_snp); ~Genome(); bool add_chr(Chr_name &); int read_region(std::ifstream & region, Parameter * para); }; class Prob_matrix { public: rate_t *p_matrix, *p_prior; // Calibration matrix and prior probabilities rate_t *base_freq, *type_likely, *type_prob; // Estimate base frequency, conditional probability, and posterior probablity rate_t *p_rank, *p_binom; // Ranksum test and binomial test on HETs Prob_matrix(); ~Prob_matrix(); int matrix_gen(std::ifstream & alignment, Parameter * para, Genome * genome); int matrix_read(std::fstream & mat_in, Parameter * para); int matrix_write(std::fstream & mat_out, Parameter * para); int prior_gen(Parameter * para); int rank_table_gen(); }; class Pos_info { public: unsigned char ori; small_int *base_info; int pos, *count_uni, *q_sum, depth, dep_uni, repeat_time, *count_all; Pos_info(){ ori = 0xFF; base_info = new small_int [4*2*64*256]; // base info : 4x2x64x64 matrix, base x strand x qual x read_pos memset(base_info,0,sizeof(small_int)*4*2*64*256); pos = -1; count_uni = new int [4]; // Count of unique bases memset(count_uni,0,sizeof(int)*4); q_sum = new int [4]; // Sum of quality of unique bases memset(q_sum,0,sizeof(int)*4); depth = 0; dep_uni = 0; repeat_time = 0; count_all = new int [4]; // Count of all bases memset(count_all,0,sizeof(int)*4); } ~Pos_info(){ delete [] base_info; delete [] count_uni; delete [] q_sum; delete [] count_all; } }; class Call_win { public: ubit64_t win_size; ubit64_t read_len; Pos_info * sites; Call_win(ubit64_t read_length, ubit64_t window_size=global_win_size) { sites = new Pos_info [window_size+read_length]; win_size = window_size; read_len = read_length; } ~Call_win(){ delete [] sites; } int initialize(ubit64_t start); int deep_init(ubit64_t start); int recycle(); int call_cns(Chr_name call_name, Chr_info* call_chr, ubit64_t call_length, Prob_matrix * mat, Parameter * para, std::ofstream & consensus, std::ofstream & baseinfo); int soap2cns(std::ifstream & alignment, std::ofstream & consensus, std::ofstream & baseinfo, Genome * genome, Prob_matrix * mat, Parameter * para); int snp_p_prior_gen(double * real_p_prior, Snp_info* snp, Parameter * para, char ref); double rank_test(Pos_info & info, char best_type, double * p_rank, Parameter * para); double normal_value(double z); double normal_test(int n1, int n2, double T1, double T2); double table_test(double *p_rank, int n1, int n2, double T1, double T2); }; #endif /*SOAP_SNP_HH_*/ SOAPsnpZ/makefile0000644000105300010600000000112711206446577014054 0ustar yuchangyuchangDEFINE = CXX = g++ CXXFLAGS = -fomit-frame-pointer -O3 -ffast-math -funroll-loops -mmmx -msse -msse2 -msse3 -fmessage-length=0 #-MMD -MP -MF #-g3 -Wall -maccumulate-outgoing-args LFLAGS = -lz all: soapsnp .PHONY: all objects: call_genotype.o chromosome.o matrix.o normal_dis.o prior.o rank_sum.o main.o $(objects): %.o: soap_snp.h makefile soapsnp: call_genotype.o chromosome.o matrix.o normal_dis.o prior.o rank_sum.o main.o makefile $(CXX) $(CXXFLAGS) call_genotype.o chromosome.o matrix.o normal_dis.o prior.o rank_sum.o main.o -o soapsnp $(LFLAGS) .PHONY: clean clean: rm -f *.o soapsnp SOAPsnpZ/readme0000644000105300010600000002065011206446507013527 0ustar yuchangyuchangProgram: SOAPsnp (Short Oligonucleotide Analysis Package for Single Nucleotide Polymorphism) Copyright (C) 2008, BGI Shenzhen. License GPLv3+: GNU GPL version 3 or later This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Author: BGI shenzhen Contact: soap@genomics.org.cn Introduction SOAPsnp is a member of the SOAP (Short Oligonucleotide Analysis Package). Despite its name, the program is a resequencing utility that can assemble consensus sequence for the genome of a newly sequenced individual based on the alignment of the raw sequencing reads on the known reference. The SNPs can then be identified on the consensus sequence through the comparison with the reference. In the first Asian genome re-sequencing project, evalution of SOAPsnp result on Illumina HapMap 1M BeadChip Duo genotyping sites shows great accuracy. Over 99% of the genotyping sites are covered at over 99.9% consistency. Further PCR plus Sanger sequencing of the inconsistent SNP sites confirmed majority of the SOAPsnp results. SOAPsnp uses a method based on Bayesa' theorem (the reverse probability model) to call consensus genotype by carefully considering the data quality, alignment, and recurring experimental errors. All these kinds of information was integrated into a single quality score for each base in PHRED scale to measure the accuracy of consensus calling. Currently, it supports the alignment format of SoapMap. Download System requirements SOAPsnp is a command line driven program written in C/C++ that generally runs under 64-bit Linux system. The program has been tested on various platforms like x86-64 Xeon with Linux kernel 2.6.9 and Loongson 2E/2F with Linux kernel 2.6.22. It is in principle portable to other architectures/systems as only standard C++ libraries were used. GNU Compiler Collection (version>=3.4) is recommended to compile the codes. The program needs ~500M or even smaller memory to run. However, its output might be very large that consumes a lot of harddisk space. In text output mode, the output file may be as large as 60 times the genome size (e.g. 180G free space is required to run a human genome). In GLF output format (which is proposed by Prof. R. Durbin in Wellcome Trust Sanger Institute), the output file approximately requires a free disk space of 12 times the genome size to store. Installation 1. Download the tarball of the latest SOAPsnp version from the link above. (For example, SOAPsnp.tar.gz) 2. In the Linux console: tar zxvf //SOAPsnp.tar.gz cd SOAPsnp/ 3. Change the 'makefile' if necessary. For example, you may would like to modify the compiler optimization parameters. 4. In the Linux console: make all Then an executable of SOAPsnp will be generated in the directory. In the Linux console, type: ./soapsnp or: /soapsnp to run the program. You may copy the executable to /usr/bin/ or other system paths defined in the environment variables so that you can simply run the program by directly typing 'soapsnp' in the console. Quick Start: For diploid genome resequencing: soapsnp -i -d -o -r 0.00005 e 0.0001 -t -u -L -M For monoploid genome resequencing: soapsnp -i -d -o -r 0.0001 -t -u -L -M -m Usage Command line options: 1. Required parameters: -i Input SORTED SOAPaligner(soap) alignment result Note that here we say 'sorted' means alignments of each chromosome are sorted first by chromosome name lexicographically and then by coordinates on each chromosome numerically. -d Reference DNA sequence in FASTA format -o Output consensus file 2. Optional parameters:(default in []) -z ASCII character that stands for quality score==0 [@] FASTQ files generated by Illumina base-calling pipeline use '@' as 0, but some institutes use '!' as 0. -g Global error dependency coefficient, 0.0(complete dependent)~1.0(complete independent)[0.9] -p PCR error dependency coefficient, 0.0(complete dependent)~1.0(complete independent)[0.5] Sequencing errors are found slightly repeatable (once an error occur, additional errors also tend to occur) due to various reasons. Therefore, observations of sequencing errors are not complete independent. The main source of repeatable errors is believed to be PCR amplification in sequencing process. The proper values of the two parameters rely on wetlab process. Nonetheless, the default value generally work at most time. -r novel altHOM prior probability [0.0005] -e novel HET prior probability [0.0010] The two are prior probabilities of homozygous SNPs (altHOM) and heterozygous SNPs (HET), which are used in Bayes formula calculation. Note these are prior probabilities of a new (novel) SNP. They are expected to be stringent. For different species, the two values should change if necessary. -t set transition/transversion ratio to 2:1 in prior probability -s Pre-formatted known SNP information. The file consist of a lot of lines like this one: chr1 201979756 1 1 0 0.161 0 0 0.839 rs568 The columns from left to right are: name of chromosome, coordinate on the chromosome, whether the SNP has allele frequency information (1 is true, 0 is false), whether the SNP is validated by experiment (1 is true, 0 is false), whether the SNP is actually an indel (1 is true, 0 is false), frequency of A, frequency of C, frequency of T, frequency of G, SNP id. For known SNP sites that do not have allele frequency information, the frequency information can be arbitrarily determined as any positive values, which only imply what alleles have already been deposited in the database. -2 specify this option will REFINE SNP calling using known SNP information [Off] -a Validated HET prior, if no allele frequency known [0.1] -b Validated altHOM prior, if no allele frequency known[0.05] -j Unvalidated HET prior, if no allele frequency known [0.02] -k Unvalidated altHOM rate, if no allele frequency known[0.01] The parameters are related to using external SNP information to alter prior probabilities for SNP calling. SOAPsnp will try using allele frequency information as prior probability in calling genotypes for each site. If the allele frequency information is absent, it will use the above 4 parameters as prior probability. -u Enable rank sum test (that check whether the two allele of a possible HET call have same sequencing quality) to give HET further penalty for better accuracy. [Off] -n Enable binomial probability calculation (that check whether the two allele are observed equally)to give HET further penalty for better accuracy. [Off] -m Enable monoploid calling mode, this will ensure all consensus as HOM and you probably should SPECIFY higher altHOM rate. [Off] -q Only output potential SNPs. Useful in Text output mode. [Off] -M Output the quality calibration matrix; the matrix can be reused with -I if you rerun the program -I Input previous quality calibration matrix. It cannot be used simutaneously with -M -L maximum length of read [45] Please note that once length of some reads exceeds the parameter will probably collapse the program. -Q maximum FASTQ quality score [40] -F Output format. 0: Text; 1: GLFv2; 2: GPFv2.[0] -E Extra headers EXCEPT CHROMOSOME FIELD specified in GLFv2 output. Format is "TypeName1:DataName1:TypeName2:DataName2"[] -T Only call consensus on regions specified in FILE. Format of this file is: ChrName\tStart\tEnd ChrName\tStart\tEnd ... -h Display this help Output format 1. Text format The result of SOAPsnp has 17 columns: 1) Chromosome ID 2) Coordinate on chromosome, start from 1 3) Reference genotype 4) Consensus genotype 5) Quality score of consensus genotype 6) Best base, average quality score of best base 7) Count of uniquely mapped best base 8) Count of all mapped best base 9) Second best bases, average quality score of second best base 10) Count of uniquely mapped second best base 11) Count of all mapped second best base 12) Sequencing depth of the site, rank sum test p_value 13) Average copy number of nearby region 14) Whether the site is a dbSNP. 2. GLFv2 and GPFv2 GLFv2 (Genome Likelihood Format v2) is a binary file format proposed by Prof. R. Durbin. SOAPsnpZ/COPYING0000644000105300010600000010451311206446525013403 0ustar yuchangyuchang GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The GNU General Public License is a free, copyleft license for software and other kinds of works. The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things. To protect your rights, we need to prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others. For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. Developers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it. For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions. Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users' freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users. Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free. The precise terms and conditions for copying, distribution and modification follow. TERMS AND CONDITIONS 0. Definitions. "This License" refers to version 3 of the GNU General Public License. "Copyright" also means copyright-like laws that apply to other kinds of works, such as semiconductor masks. "The Program" refers to any copyrightable work licensed under this License. Each licensee is addressed as "you". "Licensees" and "recipients" may be individuals or organizations. To "modify" a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a "modified version" of the earlier work or a work "based on" the earlier work. A "covered work" means either the unmodified Program or a work based on the Program. To "propagate" a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well. To "convey" a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying. An interactive user interface displays "Appropriate Legal Notices" to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion. 1. Source Code. The "source code" for a work means the preferred form of the work for making modifications to it. "Object code" means any non-source form of a work. A "Standard Interface" means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language. The "System Libraries" of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A "Major Component", in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it. The "Corresponding Source" for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work. The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source. The Corresponding Source for a work in source code form is that same work. 2. Basic Permissions. All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law. You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you. Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary. 3. Protecting Users' Legal Rights From Anti-Circumvention Law. No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures. When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures. 4. Conveying Verbatim Copies. You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program. You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee. 5. Conveying Modified Source Versions. You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions: a) The work must carry prominent notices stating that you modified it, and giving a relevant date. b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to "keep intact all notices". c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it. d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so. A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an "aggregate" if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate. 6. Conveying Non-Source Forms. You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways: a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange. b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge. c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b. d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements. e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d. A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work. A "User Product" is either (1) a "consumer product", which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, "normally used" refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product. "Installation Information" for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made. If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM). The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network. Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying. 7. Additional Terms. "Additional permissions" are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions. When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission. Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms: a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or d) Limiting the use for publicity purposes of names of licensors or authors of the material; or e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors. All other non-permissive additional terms are considered "further restrictions" within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying. If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms. Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way. 8. Termination. You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11). However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation. Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice. Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10. 9. Acceptance Not Required for Having Copies. You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so. 10. Automatic Licensing of Downstream Recipients. Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License. An "entity transaction" is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts. You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it. 11. Patents. A "contributor" is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's "contributor version". A contributor's "essential patent claims" are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, "control" includes the right to grant patent sublicenses in a manner consistent with the requirements of this License. Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version. In the following three paragraphs, a "patent license" is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To "grant" such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party. If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. "Knowingly relying" means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid. If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it. A patent license is "discriminatory" if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007. Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law. 12. No Surrender of Others' Freedom. If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program. 13. Use with the GNU Affero General Public License. Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such. 14. Revised Versions of this License. The Free Software Foundation may publish revised and/or new versions of the GNU General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation. If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program. Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version. 15. Disclaimer of Warranty. THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. Limitation of Liability. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 17. Interpretation of Sections 15 and 16. If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Also add information on how to contact you by electronic and paper mail. If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode: Copyright (C) This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, your program's commands might be different; for a GUI interface, you would use an "about box". You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see . The GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read . SOAPsnpZ/.main.cc.swp0000644000105300010600000004000011206446763014463 0ustar yuchangyuchangb0VIM 6.3LJbyuchangcompute-0-34.local/share/raid4/yuchang/work/soap/soap2/SOAPsnpZ/main.cc3210#"! UtpXYIadXr?Y l ( ]  [  M W  ca)mJeWJE( {^SNA<uoTID72  if(para->q_min == 33) { para->q_min = optarg[0]; // The char stands for quality==0 in fastq format { case 'z': } break; consensus_name = optarg; { case 'o': } break; files.ref_seq.clear(); } exit(1); cerr<<"No such file or directory:"< Output summary of consensus"< Only call consensus on regions specified in FILE. Format: ChrName\\tStart\\tEnd."< Extra headers EXCEPT CHROMOSOME FIELD specified in GLFv2 output. Format is \"TypeName1:DataName1:TypeName2:DataName2\"[""]"< Output format. 0: Text; 1: GLFv2; 2: GPFv2.[0]"< maximum FASTQ quality score [40]"< maximum length of read [45]"< Input previous quality calibration matrix. It cannot be used simutaneously with -M"< Output the quality calibration matrix; the matrix can be reused with -I if you rerun the program"< Unvalidated altHOM rate, if no allele frequency known[0.01]"< Unvalidated HET prior, if no allele frequency known [0.02]"< Validated altHOM prior, if no allele frequency known[0.05]"< Validated HET prior, if no allele frequency known [0.1]"< Pre-formated dbSNP information"< novel HET prior probability [0.0010]"< novel altHOM prior probability [0.0005]"< PCR Error Dependency Coefficient, 0.0(complete dependent)~1.0(complete independent)[0.5]"< Global Error Dependency Coefficient, 0.0(complete dependent)~1.0(complete independent)[0.9]"< ASCII chracter standing for quality==0 [@]"< Output consensus file"< Reference Sequence in fasta format"< Input SORTED Soap Result"<#include "soap_snp.h"ad$IgLzC O ! G /  \ Y X 2  d ` ] U ( % z d H , lR2'%$#} return 0; cerr<<"Consensus Done!"<read_length); mat->rank_table_gen(); mat->prior_gen(para); clog<<"Correction Matrix Done!"<matrix_read(files.matrix_file, para); else { } } mat->matrix_write(files.matrix_file, para); if (files.matrix_file) { mat->matrix_gen(files.soap_result, para, genome); //Read the soap result and give the calibration matrix if( ! is_matrix_in) { Prob_matrix * mat = new Prob_matrix; } clog<<"Read target region done."<read_region(files.region, para); if(para->region_only && files.region) { clog<<"Reading Chromosome and dbSNP information Done."<