コード例 #1
0
bool intercrossingGenerations(Rcpp::DataFrame& pedigree, int nFounders, Rcpp::IntegerVector& mpcrossID, std::vector<int>& output)
{
	#define pedFind(id) findIDInPedigree(id, pedigree)
	int nFinals = mpcrossID.size();
	int nPedigreeRows = pedigree.nrows();
	Rcpp::IntegerVector male = Rcpp::as<Rcpp::IntegerVector>(pedigree("Male")), female = Rcpp::as<Rcpp::IntegerVector>(pedigree("Female"));
	for(int finalCounter = 0; finalCounter < nFinals; finalCounter++)
	{
		int currentPedRow = pedFind(mpcrossID[finalCounter]);
		if(currentPedRow < 0 || currentPedRow > nPedigreeRows) return false;

		//Counter to stop if the loop goes too long and might be infinite
		int loopCounter = 0;
		//Pick the last row and proceed backwards up the pedigree until we're through all the selfing generations
		while(male(currentPedRow) == female(currentPedRow))
		{
			int nextPedID = male(currentPedRow);
			if(nextPedID < 0 || nextPedID > nPedigreeRows) return false;
			currentPedRow = pedFind(nextPedID);

			if(currentPedRow < 0 || currentPedRow > nPedigreeRows) return false;

			loopCounter++;
			if(loopCounter > 2000) return false;
		}
		//When we reach an NA in the pedigree the while condition will terminate, which is an error
		if((male(currentPedRow) != male(currentPedRow)) || (female(currentPedRow) != female(currentPedRow)))
		{
			return false;
		}
		int ngen = 0;
		while(male(currentPedRow) > 0)
		{
			int nextPedID = male(currentPedRow);
			if(nextPedID < 0 || nextPedID > nPedigreeRows) return false;
			currentPedRow = pedFind(nextPedID);
			if(currentPedRow < 0 || currentPedRow > nPedigreeRows) return false;

			ngen++;
			if(ngen > 2000) return false;
		}
		//another check for NA values
		if(male(currentPedRow) != male(currentPedRow))
		{
			return false;
		}
		output[finalCounter] = ngen - (int)((log(nFounders) / log(2)) + 0.5);
		if(output[finalCounter] < 0) return false;
	}
	#undef pedFind
	return true;
}
コード例 #2
0
ファイル: User.cpp プロジェクト: RJ/lastfm-desktop
 QString toString()
 {
     QStringList list;
     if (male())
         list << tr("boy") << tr("lad") << tr("chap") << tr("guy");
     else if (female())
         // I'm not sexist, it's just I'm gutless and couldn't think
         // of any other non offensive terms for women!
         list << tr("girl") << tr("lady") << tr("lass");
     else 
         return tr("person");
     
     return list.value( QDateTime::currentDateTime().toTime_t() % list.count() );
 }
コード例 #3
0
ファイル: User.cpp プロジェクト: RJ/lastfm-desktop
 bool known() const { return male() || female(); }
コード例 #4
0
void StartMainWindow( VirtualSurgeon::VirtualSurgeonParams& p)  {
	fltk3::DoubleWindow window(330,140,"Main");
	window.begin();
	
	fltk3::Button malebtn(10,10, 150,120, "Male");
	malebtn.labelsize(40);
	malebtn.callback(male_cb, 0);
	fltk3::Button female(170,10, 150,120, "Female");
	female.labelsize(40);
	female.callback(female_cb, 0);
	
	window.end();
	window.show(0,NULL);
	fltk3::run();
	
	p.is_female = !male;

	/*
	window.remove(male);
	window.remove(female);
	window.begin();
	
	fltk3::Button camera(10,10, 150,120, "Camera");
	camera.labelsize(37);
	camera.callback(camera_cb, 0);
	fltk3::Button filebtn(170,10, 150,120, "File");
	filebtn.labelsize(40);
	filebtn.callback(filebtn_cb, 0);
	
	window.end();
	window.show(0,NULL);
	fltk3::run();
	window.remove(camera);
	window.remove(filebtn);
	
	if (is_camera) {
		cv::VideoCapture capture(CV_CAP_ANY); //try to open string, this will attempt to open it as a video file
		if (!capture.isOpened())
		{
			cerr << "Failed to open a video device or video file!\n" << endl;
			return;
		}
		Mat frame;
		bool first = true;
		Ptr<OpenCVImageViewer> imgv = NULL;
		for (;;)
		{
			capture >> frame;
			if (frame.empty())
				continue;
			if (first) {
				first = !first;
				window.begin();
				imgv = new OpenCVImageViewer(frame);
				window.add(imgv);
				window.end();
				window.show(0,NULL);
			}
			imgv->setImage(frame);
			window.redraw();
		}
		
	}
	 */
}