Skip to content

Commit

Permalink
update to ver 1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
H1ppx committed Jan 26, 2019
1 parent 5cb60f2 commit c1104fd
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 47 deletions.
41 changes: 40 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,41 @@
# Hardy-Weinberg-Population-Analysis [![Build Status](https://travis-ci.org/H1ppx/Hardy-Weinberg-Population-Analysis.svg?branch=master)](https://travis-ci.org/H1ppx/Hardy-Weinberg-Population-Analysis)
# Hardy-Weinberg Population Model
Graphs the effects of population on the p value of the Hardy-Weinberg equation across generations.

## Motivation

I had a project in AP Biology to create a model of the Hardy-Weinberg Equilibrium for Google Sheets. The original project was made in Google App Scripts, however for a local version, this side project began.

## Build status

[![Build Status](https://travis-ci.org/H1ppx/Hardy-Weinberg-Population-Analysis.svg?branch=master)](https://travis-ci.org/H1ppx/Hardy-Weinberg-Population-Analysis)
[![CodeFactor](https://www.codefactor.io/repository/github/h1ppx/hardy-weinberg-population-analysis/badge)](https://www.codefactor.io/repository/github/h1ppx/hardy-weinberg-population-analysis)
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/c713270108854dc98e7954cdb1623b59)](https://www.codacy.com/app/H1ppx/Hardy-Weinberg-Population-Analysis?utm_source=github.com&utm_medium=referral&utm_content=H1ppx/Hardy-Weinberg-Population-Analysis&utm_campaign=Badge_Grade)

## Screenshots
![Alt text](screenshots/screenshot.PNG?raw=true "Title")

## Framework used
<b>Built with</b>
- [Gradle](https://gradle.org/)

## Installation
Provide step by step series of examples and explanations about how to get a development env running.

## How to use?
Input starting with the initial P value and amount of generations to simulate. Afterwords just add the population sizes and watch the sample graph adapt to your new data. When you are ready, click the export button and import the csv to excel or google sheets for further analysis.

## [License]

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

https://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Apache © [William Chu](https://github.com/H1ppx)
18 changes: 6 additions & 12 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,30 +1,24 @@
group 'willChu'
version '0.1'

plugins {
id 'org.openjfx.javafxplugin' version '0.0.6'
id 'java'
id 'application'
}

group 'willChu'
version '1.0.0'
mainClassName = 'HWE'

repositories {
mavenCentral()
}

javafx {
modules = [ 'javafx.controls', 'javafx.fxml' ]
}

dependencies {
testCompile group: 'junit', name: 'junit', version: '4.12'
compile 'com.google.api-client:google-api-client:1.23.0'
compile 'com.google.oauth-client:google-oauth-client-jetty:1.23.0'
compile 'com.google.apis:google-api-services-sheets:v4-rev505-1.23.0'
compile "com.opencsv:opencsv:4.0"
}

jar {
from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } }
manifest {
attributes 'Main-Class': 'Main'
attributes 'Main-Class': 'HWE'
}
}
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.0-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-5.0-all.zip
Binary file added screenshots/screenshot.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
33 changes: 22 additions & 11 deletions src/main/java/HWE.java
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
import com.opencsv.CSVWriter;
import javafx.application.Application;
import javafx.application.Platform;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.chart.LineChart;
import javafx.scene.chart.NumberAxis;
import javafx.scene.chart.XYChart;
import javafx.scene.control.*;
import javafx.scene.layout.HBox;
import javafx.scene.layout.StackPane;
import javafx.scene.layout.VBox;
import javafx.scene.paint.Color;
import javafx.scene.shape.Circle;
Expand Down Expand Up @@ -41,23 +38,25 @@ public void start(Stage stage) throws Exception {
lineChart.setTitle("P Value vs Generation vs Population Size");
lineChart.setCreateSymbols(false);

ArrayList<ArrayList> csvData = new ArrayList<>();

Scene scene = new Scene(new Group());

Label pLabel = new Label("Start P:");
TextField pTextfield = new TextField();
pTextfield.setPromptText("Between 0 and 1 Only");

Label genLabel = new Label("Generations:");
TextField genTextField = new TextField();
genTextField.setPromptText("Integer Only");

Label popLabel = new Label("Population Size:");
TextField popTextField = new TextField();
popTextField.setPromptText("Integer Only");

Button add1 = new Button("Add");
Button add2 = new Button("Add");
Button add3 = new Button("Add");
Button export = new Button("Export Data");
Button reset = new Button("Reset All");

Circle confirm1 = new Circle(15, Color.RED);
Circle confirm2 = new Circle(15, Color.RED);
Expand All @@ -72,7 +71,7 @@ public void start(Stage stage) throws Exception {
hboxP.getChildren().addAll(pLabel, pTextfield, add1, confirm1);
hboxGen.getChildren().addAll(genLabel, genTextField, add2, confirm2);
hboxPop.getChildren().addAll(popLabel, popTextField, add3);
hBoxExport.getChildren().addAll(export);
hBoxExport.getChildren().addAll(export, reset);


hboxP.setSpacing(10);
Expand Down Expand Up @@ -111,8 +110,6 @@ public void start(Stage stage) throws Exception {

XYChart.Series tempSeries = new XYChart.Series();
tempSeries.setName("Population:" + popSize);
ArrayList<Double> tempfile;


ArrayList<Double> pVals = getP(pVal, popSize, genAmount);
for (double i = 0; i<=pVals.size()-1; i++){
Expand All @@ -127,7 +124,7 @@ public void start(Stage stage) throws Exception {
export.setOnAction(event -> {
Writer writer = null;
try {
writer = Files.newBufferedWriter(Paths.get("./test.csv"));
writer = Files.newBufferedWriter(Paths.get("./data.csv"));
} catch (IOException e) {
e.printStackTrace();
}
Expand All @@ -136,7 +133,7 @@ public void start(Stage stage) throws Exception {
CSVWriter.NO_QUOTE_CHARACTER,
CSVWriter.DEFAULT_ESCAPE_CHARACTER,
CSVWriter.DEFAULT_LINE_END);

String[] headerRecord = new String[lineChart.getData().size()+1];
headerRecord[0] = "Gen Count";
for (int i = 1; i < lineChart.getData().size()+1; i++){
Expand All @@ -161,6 +158,21 @@ public void start(Stage stage) throws Exception {
}
});

reset.setOnAction(event -> {
pTextfield.setEditable(true);
pTextfield.clear();
confirm1.setFill(Color.RED);
hboxP.getChildren().add(2, add1);

genTextField.setEditable(true);
genTextField.clear();
confirm2.setFill(Color.RED);
hboxGen.getChildren().add(2, add2);

lineChart.getData().clear();

});

((Group)scene.getRoot()).getChildren().add(vbox);
stage.setScene(scene);
stage.show();
Expand All @@ -185,7 +197,6 @@ private ArrayList<Double> getP(final double startP, final int populationSize, fi
pVals.add(p);
p = getNextP(p, populationSize);
}

return pVals;
}

Expand Down
22 changes: 0 additions & 22 deletions test.csv

This file was deleted.

0 comments on commit c1104fd

Please sign in to comment.