Init version
This commit is contained in:
216
DEC_GUI/derrep2014window.cpp
Normal file
216
DEC_GUI/derrep2014window.cpp
Normal file
@@ -0,0 +1,216 @@
|
||||
#include "derrep2014window.h"
|
||||
#include "ui_derrep2014window.h"
|
||||
#include "DEC-0.0/processor/Settings.h"
|
||||
#include "DEC-0.0/DerevyankoReport2014.h"
|
||||
#include <fstream>
|
||||
#include <cstdio>
|
||||
#include <ctime>
|
||||
#include <cstdlib>
|
||||
|
||||
DerRep2014Window::DerRep2014Window(QWidget *parent) :
|
||||
QWidget(parent),
|
||||
ui(new Ui::DerRep2014Window)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
graphFlag = true;
|
||||
//setParametersSettings();
|
||||
//ui->calcProgress_progressBar->setValue(0);
|
||||
//ui->calcProgress_progressBar->setMinimum(0);
|
||||
connect(this, SIGNAL(drawDefault(QCustomPlot *)), &derRep2014Qplot, SLOT(drawGraphics(QCustomPlot*)));
|
||||
connect(this, SIGNAL(drawDefaultSeparate(QCustomPlot*)), &derRep2014Qplot, SLOT(drawSepGenderGraphics(QCustomPlot*)));
|
||||
emit drawDefault(ui->Plot_widget);
|
||||
|
||||
|
||||
}
|
||||
|
||||
DerRep2014Window::~DerRep2014Window()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void DerRep2014Window::setParametersSettings()
|
||||
{
|
||||
ui->popHInSize_spinBox->setRange(0, 1000000);
|
||||
ui->popHInSize_spinBox->setSingleStep(100);
|
||||
ui->popHInSize_spinBox->setValue(Settings::PopulationHomoInitSize);
|
||||
ui->popAnInitSize_spinBox->setRange(0, 1000000);
|
||||
ui->popAnInitSize_spinBox->setSingleStep(100);
|
||||
ui->popAnInitSize_spinBox->setValue(Settings::PopulationAncientInitSize);
|
||||
ui->birthRate_doubleSpinBox->setRange(0, 100);
|
||||
ui->birthRate_doubleSpinBox->setSingleStep(0.01);
|
||||
ui->birthRate_doubleSpinBox->setValue(Settings::BirthRate);
|
||||
ui->deathRate_doubleSpinBox->setRange(0, 10000);
|
||||
ui->deathRate_doubleSpinBox->setSingleStep(0.01);
|
||||
ui->deathRate_doubleSpinBox->setValue(Settings::NaturalDeathRate);
|
||||
ui->gensPerMigr_spinBox->setRange(0, 10000);
|
||||
ui->gensPerMigr_spinBox->setSingleStep(10);
|
||||
ui->gensPerMigr_spinBox->setValue(Settings::generationsPerMigration);
|
||||
ui->migrA_to_H_doubleSpinBox->setRange(0, 10000);
|
||||
ui->migrA_to_H_doubleSpinBox->setSingleStep(0.1);
|
||||
ui->migrA_to_H_doubleSpinBox->setValue(Settings::migrationPartAncientToHomo);
|
||||
ui->migrH_to_A_doubleSpinBox->setRange(0, 10000);
|
||||
ui->migrH_to_A_doubleSpinBox->setSingleStep(0.1);
|
||||
ui->migrH_to_A_doubleSpinBox->setValue(Settings::migrationPartHomoToAncient);
|
||||
ui->evolTime_spinBox->setRange(0, 1000000);
|
||||
ui->evolTime_spinBox->setSingleStep(100);
|
||||
ui->evolTime_spinBox->setValue(100);
|
||||
ui->evol_migr_spinBox->setRange(0, 1000000);
|
||||
ui->evol_migr_spinBox->setSingleStep(100);
|
||||
ui->evol_migr_spinBox->setValue(100);
|
||||
ui->pop_comboBox->addItem("Pop_Homo", QVariant(0));
|
||||
ui->pop_comboBox->addItem("Pop_Ancient", QVariant(1));
|
||||
//ui->Gene_textEdit->addScrollBarWidget();
|
||||
|
||||
}
|
||||
|
||||
void DerRep2014Window::startDefault()
|
||||
{
|
||||
emit drawDefault(ui->Plot_widget);
|
||||
}
|
||||
|
||||
void DerRep2014Window::on_showGender_pushButton_clicked()
|
||||
{
|
||||
if (graphFlag)
|
||||
{
|
||||
emit drawDefaultSeparate(ui->Plot_widget);
|
||||
graphFlag = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
emit drawDefault(ui->Plot_widget);
|
||||
graphFlag = true;
|
||||
}
|
||||
}
|
||||
|
||||
void DerRep2014Window::on_evolution_pushButton_clicked()
|
||||
{
|
||||
int iter = ui->evolTime_spinBox->value();
|
||||
//ui->calcProgress_progressBar->setValue(0);
|
||||
//ui->calcProgress_progressBar->setMaximum(iter);
|
||||
Settings::BirthRate = ui->birthRate_doubleSpinBox->value();
|
||||
Settings::NaturalDeathRate = ui->deathRate_doubleSpinBox->value();
|
||||
DerevyankoReport2014::evolution(iter);
|
||||
|
||||
|
||||
if (!graphFlag)
|
||||
{
|
||||
emit drawDefaultSeparate(ui->Plot_widget);
|
||||
}
|
||||
else
|
||||
{
|
||||
emit drawDefault(ui->Plot_widget);
|
||||
}
|
||||
}
|
||||
|
||||
void DerRep2014Window::on_migration_pushButton_clicked()
|
||||
{
|
||||
Settings::migrationPartAncientToHomo = ui->migrA_to_H_doubleSpinBox->value();
|
||||
Settings::migrationPartHomoToAncient = ui->migrH_to_A_doubleSpinBox->value();
|
||||
DerevyankoReport2014::migration();
|
||||
if (!graphFlag)
|
||||
{
|
||||
emit drawDefaultSeparate(ui->Plot_widget);
|
||||
}
|
||||
else
|
||||
{
|
||||
emit drawDefault(ui->Plot_widget);
|
||||
}
|
||||
}
|
||||
|
||||
void DerRep2014Window::on_evol_migr_pushButton_clicked()
|
||||
{
|
||||
int iter = ui->evol_migr_spinBox->value();
|
||||
//ui->calcProgress_progressBar->setValue(0);
|
||||
//ui->calcProgress_progressBar->setMaximum(iter);
|
||||
Settings::generationsPerMigration = ui->gensPerMigr_spinBox->value();
|
||||
Settings::BirthRate = ui->birthRate_doubleSpinBox->value();
|
||||
Settings::NaturalDeathRate = ui->deathRate_doubleSpinBox->value();
|
||||
Settings::migrationPartAncientToHomo = ui->migrA_to_H_doubleSpinBox->value();
|
||||
Settings::migrationPartHomoToAncient = ui->migrH_to_A_doubleSpinBox->value();
|
||||
DerevyankoReport2014::evolution_migr(iter);
|
||||
if (!graphFlag)
|
||||
{
|
||||
emit drawDefaultSeparate(ui->Plot_widget);
|
||||
}
|
||||
else
|
||||
{
|
||||
emit drawDefault(ui->Plot_widget);
|
||||
}
|
||||
}
|
||||
|
||||
void DerRep2014Window::changeProgrBarVal(int iter)
|
||||
{
|
||||
//ui->calcProgress_progressBar->setValue(iter);
|
||||
}
|
||||
|
||||
void DerRep2014Window::on_pop_comboBox_currentIndexChanged(int index) //maybe need to call it every elov action?
|
||||
{
|
||||
int ind = ui->pop_comboBox->itemData(ui->pop_comboBox->currentIndex()).toInt();
|
||||
if (ind == 0)
|
||||
{
|
||||
ui->Gene_textEdit->clear();
|
||||
ui->Gene_textEdit->setTextBackgroundColor(Qt::cyan);
|
||||
ui->Gene_textEdit->setText("Males");
|
||||
int i = 0;
|
||||
for (std::list<Individual*>::iterator it = DerevyankoReport2014::pop_Sapiens->males.begin(); it != DerevyankoReport2014::pop_Sapiens->males.end(); it++)
|
||||
{
|
||||
i++;
|
||||
if (i < 10)
|
||||
{
|
||||
ui->Gene_textEdit->append(QString::fromStdString((*it)->getGenotype().toSimpleFasta()));
|
||||
}
|
||||
}
|
||||
ui->Gene_textEdit->setTextBackgroundColor(Qt::magenta);
|
||||
ui->Gene_textEdit->append("Females");
|
||||
int j = 0;
|
||||
for (std::list<Individual*>::iterator it = DerevyankoReport2014::pop_Sapiens->females.begin(); it != DerevyankoReport2014::pop_Sapiens->females.end(); it++)
|
||||
{
|
||||
j++;
|
||||
if (j < 10)
|
||||
{
|
||||
ui->Gene_textEdit->append(QString::fromStdString((*it)->getGenotype().toSimpleFasta()));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
if (ind == 1)
|
||||
{
|
||||
ui->Gene_textEdit->clear();
|
||||
ui->Gene_textEdit->setTextBackgroundColor(Qt::cyan);
|
||||
ui->Gene_textEdit->setText("Males");
|
||||
int i = 0;
|
||||
for (std::list<Individual*>::iterator it = DerevyankoReport2014::pop_Ancient->males.begin(); it != DerevyankoReport2014::pop_Ancient->males.end(); it++)
|
||||
{
|
||||
i++;
|
||||
//std::string str = (*it)->getGenotype().toSimpleFasta();
|
||||
//QString lol = QString::fromStdString(str.substr(i * 200));
|
||||
if (i < 10)
|
||||
{
|
||||
ui->Gene_textEdit->append(QString::fromStdString((*it)->getGenotype().toSimpleFasta()));
|
||||
}
|
||||
|
||||
//std::cout << lol << std::endl;
|
||||
}
|
||||
ui->Gene_textEdit->setTextBackgroundColor(Qt::magenta);
|
||||
ui->Gene_textEdit->append("Females");
|
||||
int j = 0;
|
||||
for (std::list<Individual*>::iterator it = DerevyankoReport2014::pop_Ancient->females.begin(); it != DerevyankoReport2014::pop_Ancient->females.end(); it++)
|
||||
{
|
||||
j++;
|
||||
if (j < 10)
|
||||
{
|
||||
ui->Gene_textEdit->append(QString::fromStdString((*it)->getGenotype().toSimpleFasta()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DerRep2014Window::on_saveStat_pushButton_clicked()
|
||||
{
|
||||
std::ofstream file("GenStatistics.pop_Sapiens.fasta");
|
||||
DerevyankoReport2014::pop_Sapiens->putGeneticStatisticsToStream(file);
|
||||
file.close();
|
||||
std::ofstream file1("GenStatistics.pop_Ancient.fasta");
|
||||
DerevyankoReport2014::pop_Ancient->putGeneticStatisticsToStream(file1);
|
||||
file1.close();
|
||||
}
|
||||
Reference in New Issue
Block a user