Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Executable installer and GUI launcher #354

Merged
merged 56 commits into from
Feb 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
0c5af96
Draft installer
LimesKey Dec 30, 2022
1ac6428
compiled ps1 executable
LimesKey Dec 30, 2022
5661dad
Increased readability and comments, less redundent code
LimesKey Dec 31, 2022
f7042af
fixed minor typo
LimesKey Dec 31, 2022
75c5d46
ChatGPT Formatted
LimesKey Dec 31, 2022
5927901
Merge branch 'Verisimilitude11:main' into main
LimesKey Dec 31, 2022
c9675c2
Bug fixed the function variable issue
LimesKey Jan 3, 2023
5241df0
Bug fixes, Increased readability and better variable naming
LimesKey Jan 3, 2023
1e75cc0
Updated with the new PS1 Script
LimesKey Jan 3, 2023
a152c3e
Reformatted code
LimesKey Jan 3, 2023
9e8fd25
Update installer.ps1
LimesKey Jan 3, 2023
9dddd1f
Add files via upload
LimesKey Jan 3, 2023
4d81948
Merge branch 'main' into main
VerisimilitudeX Jan 3, 2023
8a23e36
too large
LimesKey Jan 5, 2023
f21244d
Add files via upload
LimesKey Jan 5, 2023
b8ea1df
Delete testing.fa
LimesKey Jan 5, 2023
5fe2680
better size
LimesKey Jan 5, 2023
0daacb3
uppercase
LimesKey Jan 5, 2023
6426ff7
only upper
LimesKey Jan 5, 2023
ce6081d
Merge branch 'Verisimilitude11:main' into main
LimesKey Jan 7, 2023
a1556b9
Added instruction for using the executable file
LimesKey Jan 7, 2023
2154ddb
Merge branch 'Verisimilitude11:main' into main
LimesKey Jan 11, 2023
9c5c63b
Update Gradle from V2 --> V2.3.3
LimesKey Jan 11, 2023
bb14f12
Merge branch 'main' into main
LimesKey Jan 12, 2023
9e4b664
temp fix
LimesKey Jan 12, 2023
8f03422
temp fix
LimesKey Jan 12, 2023
9914df6
temp fix
LimesKey Jan 12, 2023
cb9861b
Unnecessary imports detected temp
LimesKey Jan 12, 2023
cb85f5b
Update DNAAnalysisTest.java
LimesKey Jan 12, 2023
0fac5d8
Merge pull request #339 from LimesKey/main
LimesKey Jan 12, 2023
f192a1b
Fixed GUI Launching issue
LimesKey Jan 12, 2023
4e7b0da
Updated formatting, better wording
LimesKey Jan 12, 2023
fffb984
text formatting
LimesKey Jan 12, 2023
39e5d5b
Rename installer.ps1 to src/main/resources/Powershell/download-instal…
LimesKey Jan 12, 2023
ddb0585
download latest verison of Java
LimesKey Jan 12, 2023
9b1f0fa
Create install_config.yml
LimesKey Jan 12, 2023
27dda05
Update README.md
LimesKey Jan 12, 2023
5ac9235
how to install guide
LimesKey Jan 13, 2023
cab8bda
Update Installer.md
LimesKey Jan 13, 2023
e6a8a8c
updated from latest powershell installer commit
LimesKey Jan 13, 2023
f5481d2
Merge branch 'main' into Executable-installer-and-GUI-Launcher
LimesKey Jan 14, 2023
c62d0d7
Merge branch 'main' into Executable-installer-and-GUI-Launcher
VerisimilitudeX Jan 16, 2023
06bfb16
Merge branch 'main' into Executable-installer-and-GUI-Launcher
VerisimilitudeX Jan 20, 2023
de8e085
Self-Signed Cert & Updated file description and name
LimesKey Jan 22, 2023
a67fa6f
Update ProteinFinderTest.java
LimesKey Jan 22, 2023
13090ee
Update DNAAnalysisTest.java
LimesKey Jan 22, 2023
57f3247
Update PropertiesTest.java
LimesKey Jan 22, 2023
d57c96b
Update dnalong.fa
LimesKey Jan 22, 2023
1fe059d
Merge branch 'Executable-installer-and-GUI-Launcher' of https://githu…
LimesKey Jan 22, 2023
3021b4c
Update PropertiesTest.java
LimesKey Jan 22, 2023
af79e59
Create testing.fa
LimesKey Jan 22, 2023
551aac3
Merge branch 'main' into Executable-installer-and-GUI-Launcher
VerisimilitudeX Jan 23, 2023
f4cdc99
Reverted dnalong.fa to commit 33b098104ce31965d0e2940e50c5ad840da56e91
LimesKey Jan 23, 2023
743b048
Reverted file
LimesKey Jan 23, 2023
7748839
x
LimesKey Jan 23, 2023
1120d2c
Merge branch 'main' into Executable-installer-and-GUI-Launcher
VerisimilitudeX Feb 10, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added DNAnalyzer-Installer.exe
Binary file not shown.
20 changes: 16 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ The human genome is composed of over 3 billion base pairs, making human analysis

### DNA

In a nutshell, DNA is found in every cell of your body and contains the instructions for building over 200 different types of cells. DNA is similar to a programming language, but only for living organisms. We can crack the code to reading and interpreting it by using Artificial Intelligence and Machine Learning, which can have life-saving benefits as well as key insights.
DNA, present in every cell of the body, holds the blueprint for creating over 200 distinct cell types. Like a programming language, it is exclusive to living organisms. With the aid of Artificial Intelligence and Machine Learning, we can decode and comprehend DNA, leading to potentially life-saving discoveries and valuable insights.

### Databases

Having a database of DNA is the best way to interpret the DNA, and when combined with machine learning, the ML model can make accurate predictions on DNA it has never seen before. This is how current DNA tests function.
A DNA database is crucial for interpreting DNA sequences. By leveraging machine learning, predictions can be made on previously unseen DNA sequences. This is the foundation on which current DNA analysis programs operate.

## Getting Started

Expand All @@ -58,13 +58,20 @@ A [video tutorial](https://youtu.be/dOwkInn6eDw) covering the instructions below
### System Requirements

* JDK [17](https://www.oracle.com/java/technologies/downloads/#jdk17-windows)+
* A `JAVA_HOME` environment variable pointing to your JDK, or the Java executable in your PATH
* [Gradle](https://gradle.org/install/)
* A `JAVA_HOME` environment variable pointing to your JDK, or the Java executable in your PATH
* [Gradle](https://gradle.org/install/) (included)

### Build & Run

The easiest way to run the program on Windows is by using the executable file located in the [releases](https://github.com/Verisimilitude11/DNAnalyzer/releases/latest) section to install the program, build gradle and run the GUI.

* Note: Ensure you have Java [17](https://www.oracle.com/java/technologies/downloads/#jdk17-windows) or higher installed and a `JAVA_HOME` path variable set for the program to function correctly!

We use [Gradle](https://gradle.org) for building. The Gradle wrapper takes care of downloading dependencies, testing, compiling, linking, and packaging the code.

<details>
<summary>Linux and compilation from source</summary>

```pwsh
./gradlew build
```
Expand Down Expand Up @@ -111,13 +118,18 @@ DNAnalyzer also comes with a (very basic) GUI; to start DNAnalyzer with the GUI,
./gradlew run --args="--gui assets/dna/random/dnalong.fa"
```


Then:

* Enter the file name of the DNA file in the text field
* Set min and max
* Click analyze


The results of your analysis will be shown in the right pane.
</details>

#

#### Help message

Expand Down
6,454 changes: 6,454 additions & 0 deletions assets/dna/real/TGFBR3-gene.fasta

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions src/main/resources/Powershell/Installer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

## How to edit the Powershell files and create your own executable!
2 changes: 2 additions & 0 deletions src/main/resources/Powershell/JavaInstaller.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[System.Environment]::SetEnvironmentVariable("JAVA_HOME", "C:\Program Files\Java\jdk-17.0.5")
[System.Environment]::SetEnvironmentVariable("Path", [System.Environment]::GetEnvironmentVariable('Path', [System.EnvironmentVariableTarget]::Machine) + ";$($env:JAVA_HOME)\bin")
203 changes: 203 additions & 0 deletions src/main/resources/Powershell/download-installer.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,203 @@
# Specify the downloads folder
$downloads_folder = (New-Object -ComObject Shell.Application).NameSpace('shell:Downloads').Self.Path

$ErrorActionPreference = 'SilentlyContinue'
$ProgressPreference = 'SilentlyContinue' # adds increased downloading speed

# Set the path for the DNAnalyzer directory in the downloads folder
$dir_path = "$downloads_folder/DNAnalyzer"

try {
# Check if the directory already exists
if ([System.IO.Directory]::Exists($dir_path)) {
Write-Host "The directory already exists."
} else {
# Try to create the directory for DNAnalyzer in the downloads folder
New-Item -Path "$downloads_folder/DNAnalyzer/" -ItemType Directory
}
} catch [System.Exception] {
# Catch any errors and print a message
Write-Host "Something went wrong..." -ForegroundColor Red
Write-Error $_.Exception.Message
}

# Set the URL for the latest release and the source code
$url = 'https://github.com/Verisimilitude11/DNAnalyzer/releases/latest'
$alt_url = 'https://github.com/Verisimilitude11/DNAnalyzer/archive/refs/tags/'

# Make a request to the URL and get the response
$request = [System.Net.WebRequest]::Create($url)
$response = $request.GetResponse()

# Get the original URL of the response
$realTagUrl = $response.ResponseUri.OriginalString

# Split the URL by '/' and get the last element, then remove the 'v' prefix
$version = $realTagUrl.split('/')[-1].Trim('v')

# Set the published asset download URL and the source code download URL
$realDownloadUrl = "$realTagUrl/download/DNAnalyzer-$version.zip"
$Alt_realDownloadUrl = "$alt_url" + 'v' + "$version.zip"

Function Installation {
param($version, $Download_URL, $dir_path, $fileName, $Live_URL)

Write-Host "Attempting to fetch file, please wait..."

try {
# Download the file from the specified URL
Invoke-WebRequest -Uri $Download_URL[$Live_URL] -OutFile "$($dir_path)/$($fileName[$Live_URL]).zip"
} catch {
# Catch any errors and print a message
Write-Host "Fetch Failed," "StatusCode:" $Error -ForegroundColor Red
Pause
}

# Check if the file was successfully downloaded
if ([System.IO.File]::Exists("$($dir_path)/$($fileName[$Live_URL]).zip")) {
Write-Host "Fetch Sucessful!" -ForegroundColor Green
Write-Host "Version:" -ForegroundColor Green $version

try {
# Uncompress the archive
Expand-Archive -Path "$($dir_path)/$($fileName[$Live_URL]).zip" -DestinationPath "$($dir_path)/$($fileName[$Live_URL])"
} catch {
# Catch any errors and print a message
Write-Host "Failed to uncomperess archieve!"
}
}
}

function Before_installation_checks {
param($version, $dir_path, $Download_URL, $fileName, $Live_URL)

# Check if already installed
if ([System.IO.File]::Exists("$($dir_path)/$($fileName[$Live_URL])")) {
Write-Host ("Latest verison already installed") -ForegroundColor Green
Write-Host "Version:" -ForegroundColor Green $version
Pause
}
# Check if the zipped file for the correct version exists, but the folder does not
elseif ([System.IO.File]::Exists("$($dir_path)/$($fileName[$Live_URL]).zip")) {
Write-Host 'Trying to uncompress archieve...'
try {
# Attempt to expand the zip file
Expand-Archive -Path "$($dir_path)/$($fileName[$Live_URL]).zip" -DestinationPath "$($dir_path)/$($fileName[$Live_URL])"
} catch {
Write-Host "Failed to uncomperss archieve!" -ForegroundColor Red
Pause
} else {
try {
# Attempt to remove the zip file
Remove-Item "$($dir_path)/$($fileName[$Live_URL]).zip"
} catch {
Write-Host 'Failed to remove zipped folder.' -ForegroundColor Red
Write-Host 'Permisson Error?'
} else {
# Check if the folder for the correct version already exists
if ([System.IO.File]::Exists("$($dir_path)/$($fileName[$Live_URL])")) {
Write-Host ("Latest verison sucessfully unzipped!") -ForegroundColor Green
Write-Host "Location:" $dir_path/$fileName[$Live_URL] -ForegroundColor Green
}
}
}
}
if (-not (Test-Path -Path ("$($dir_path)/$($fileName[$Live_URL]).zip")) -and -not (Test-Path -Path "$($dir_path)/$($fileName[$Live_URL])")) {
# If neither zipped file or folder exists with the correct version, start installation
Write-Host 'File/Folder not already found on system.'
Installation $version $Download_URL $dir_path $fileName $Live_URL # Call installation process function
}
}

## Introduction

# Store the URLs in an array
$Download_URL = @("$realDownloadUrl", "$Alt_realDownloadUrl")

try {
# Check the content type of the source code asset and published asset
$alt_response = Invoke-WebRequest -Method Head -Uri $Download_URL[1] -UseBasicParsing
$alt_content = $alt_response.Headers."Content-Type"
# $alt_content source code

$response = Invoke-WebRequest -Method Head -Uri $Download_URL[0] -UseBasicParsing
$content = $response.Headers."Content-Type"
# $content actual release
}
catch [System.Net.WebException] {
if ($null -eq $content -and $null -eq $alt_content) {
Write-Host 'Internet error maybe?' -ForegroundColor Red
Pause
}
}
catch {
# Catch any other errors and print a message
Write-Host 'Something went wrong...' -ForegroundColor Red
$Error
}

finally {
# If the 'actual release' content type is a zip file, proceed with installation

$fileName = @("DNAnalyzer-$version", "DNAnalyzer-$version-BETA_SOURCE")

if ($content -eq 'application/zip') {
# Actual Release
$Live_URL = 0
Before_installation_checks $version $dir_path $Download_URL $fileName $Live_URL
}

# If the 'source code' content type is a zip file, proceed with installation
elseif ($alt_content -eq 'application/zip') {
# Source code
$Live_URL = 1
Before_installation_checks $version $dir_path $Download_URL $fileName $Live_URL
}

else {
# If the content type is not a zip file, print an error message
Write-Host 'Something went wrong...' -ForegroundColor Red
$Error
Pause
}

}

# Clean up and compilation
if ([System.IO.File]::Exists("$($dir_path)/$($fileName[$Live_URL]).zip")) { # if zipped file exists
# Remove the zip file
try {
# Attempt to remove the zip file
Remove-Item "$($dir_path)/$($fileName[$Live_URL]).zip"
}
catch {
Write-Host 'Failed to remove zipped folder.' -ForegroundColor Red
$Error
}
$subfolder_location = Get-ChildItem -Path "$($dir_path)/$($fileName[$Live_URL])/" -Filter "*DNAnalyzer*" -Directory
$items = Get-ChildItem -Path "$($dir_path)/$($fileName[$Live_URL])/$($subfolder_location)"
$items | ForEach-Object {
Move-Item -Path $_.FullName -Destination "$($dir_path)/$($fileName[$Live_URL])"
}

if (Test-Path "$($dir_path)/$($fileName[$Live_URL])/$($fileName[0])") {
Remove-Item -Path "$($dir_path)/$($fileName[$Live_URL])/$($fileName[0])" -Recurse
}
}

# Change the location to the unzipped folder
Set-Location -Path "$($dir_path)/$($fileName[$Live_URL])/$($subfolder_location)"
$installer_location = Get-Location
explorer "$installer_location"
# Runs the gradle build and run commands
try {
./gradlew build
./gradlew run --args="--gui assets/dna/random/dnalong.fa"
}
catch { # prints the error
Write-Host ($Error) -ForegroundColor Red
}

# Print a success message
Write-Host ("Installation Complete!") -ForegroundColor Green
Write-Host "Version:" -ForegroundColor Green $version
1 change: 1 addition & 0 deletions src/main/resources/Powershell/install_config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@