示例#1
0
static void
print_flist_1(
	flist_t		*flist,
	char		**ppfx,
	int		parentoff)
{
	char		buf[16];
	const field_t	*f;
	const ftattr_t	*fa;
	flist_t		*fl;
	int		low;
	int		neednl;
	char		**pfx;

	for (fl = flist; fl && !seenint(); fl = fl->sibling) {
		pfx = copy_strvec(ppfx);
		if (fl->name[0])
			add_strvec(&pfx, fl->name);
		if (fl->flags & FL_OKLOW) {
			add_strvec(&pfx, "[");
			snprintf(buf, sizeof(buf), "%d", fl->low);
			add_strvec(&pfx, buf);
			if (fl->low != fl->high) {
				add_strvec(&pfx, "-");
				snprintf(buf, sizeof(buf), "%d", fl->high);
				add_strvec(&pfx, buf);
			}
			add_strvec(&pfx, "]");
		}
		if (fl->child) {
			if (fl->name[0])
				add_strvec(&pfx, ".");
			print_flist_1(fl->child, pfx, fl->offset);
		} else {
			f = fl->fld;
			fa = &ftattrtab[f->ftyp];
			ASSERT(fa->ftyp == f->ftyp);
			print_strvec(pfx);
			dbprintf(" = ");
			if (fl->flags & FL_OKLOW)
				low = fl->low;
			else
				low = 0;
			if (fa->prfunc) {
				neednl = fa->prfunc(iocur_top->data, fl->offset,
					fcount(f, iocur_top->data, parentoff),
					fa->fmtstr,
					fsize(f, iocur_top->data, parentoff, 0),
					fa->arg, low,
					(f->flags & FLD_ARRAY) != 0);
				if (neednl)
					dbprintf("\n");
			} else {
				ASSERT(fa->arg & FTARG_OKEMPTY);
				dbprintf(_("(empty)\n"));
			}
		}
		free_strvec(pfx);
	}
}
示例#2
0
int main (int argc, char** argv){

	double timing = get_time();
	double start_time = timing;

	Parameter myPara (argc, argv);
	GlobalParam gParam;

	// -------------------------------------------------------------------

	//std::cout << "Get input bam file list...\n\n";
	//xny::getInputFilelist (gParam.bam_filelist, "bam", myPara.iDirNm);

	gParam.bam_filelist.push_back(myPara.iDirNm);

	if (gParam.bam_filelist.size() == 0) abording ("no .bam file found");
	else {
		int sz = gParam.bam_filelist.size();
		std::cout << "\n\t" << sz  << " bam file(s) found: \n";
		print_strvec ("\t\t", gParam.bam_filelist);
	}

	// -------------------------------------------------------------------

	std::cout << "\nParse bam header: get refSeq info & sanity check\n\n";
	parse_bam_header (gParam, myPara.pSample);

	// -------------------------------------------------------------------

	std::cout << "\nGet maxQ, minQ, maxReadLen, avgFragSz, "
			"stdFragSz from bam files ...\n\n";

	int min_qual, max_qual;
	sampling (min_qual, max_qual, gParam.maxRL, gParam.avgFragSz,
			gParam.stdFragSz, gParam.bam_filelist, myPara.pSample);
	if (max_qual - min_qual + 1 < myPara.var_qt) {
		myPara.var_qt = max_qual - min_qual + 1;
		std::cout << "\tqQuantile is reset to " << myPara.var_qt << "\n";
	}

	// -------------------------------------------------------------------
	std::cout << "\nGenerate qual -> quantile map ... \n\n";

	qqMap (gParam.qq, min_qual, max_qual, myPara.var_qt);

	// -------------------------------------------------------------------
	std::cout << "\nSet up paired read map arrays ... \n\n";
	set_rmap_array (gParam, myPara);
	//set_arrays (gParam, qq, myPara);

	// remeasure fragment size based on paired read alignment as the
	// BAM file did not properly record such information
	if (gParam.avgFragSz == 0) {
		ivec_t fragSz;
		std::map<std::string, MapEntry>::iterator it_am = gParam.alnMap.begin();
		for (; it_am != gParam.alnMap.end(); ++ it_am) {
			if (it_am->second.second.start >= it_am->second.first.start){
				fragSz.push_back(it_am->second.second.start -
						it_am->second.first.start);
			}
		}
		/* calculate mean frag sz and std */
		int sample_sz = fragSz.size();
		uint64_t sum = 0;
		for (int i = 0; i < sample_sz; ++ i) sum += fragSz[i];
		if (sum > 0 && sample_sz > 0) gParam.avgFragSz = sum/sample_sz;
		sum = 0;
		for (int i = 0; i < (int) fragSz.size(); ++ i) {
			sum += (gParam.avgFragSz - fragSz[i])*(gParam.avgFragSz - fragSz[i]);
		}
		if (sample_sz > 1) gParam.stdFragSz = std::sqrt(sum/sample_sz - 1);
		std::cout << "\trecalculated frag size and std" << gParam.avgFragSz
				<< ", " << gParam.stdFragSz << "\n";
	}

	// -------------------------------------------------------------------
	std::cout << "\nPrepare aln columns file...\n\n";
	prep_aln_file (gParam, myPara);

	// -------------------------------------------------------------------
	std::cout << "\nInference ...\n\n";

	EM (gParam, myPara);

	std::cout << "-----------------------------------------------------------\n\n";

    print_time("Whole program takes \t", start_time);
	std::cout << "DONE!\n";
	return (EXIT_SUCCESS);
}