Skip to content

Commit

Permalink
Merge pull request #354 from Verisimilitude11/Executable-installer-an…
Browse files Browse the repository at this point in the history
…d-GUI-Launcher

Executable installer and GUI launcher
  • Loading branch information
VerisimilitudeX authored Feb 10, 2023
2 parents fa55f4e + 1120d2c commit 2d1d748
Show file tree
Hide file tree
Showing 7 changed files with 6,678 additions and 4 deletions.
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 @@

0 comments on commit 2d1d748

Please sign in to comment.