Skip to content

Commit

Permalink
Merge branch 'main' into deepsource-transform-9dd95d07
Browse files Browse the repository at this point in the history
  • Loading branch information
VerisimilitudeX authored Oct 22, 2022
2 parents e9f0530 + bf142f0 commit 67a3587
Show file tree
Hide file tree
Showing 9 changed files with 84 additions and 53 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/static.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ jobs:
- name: Upload artifact
uses: actions/upload-pages-artifact@v1
with:
# Upload entire repository
path: '.'
# Upload all content under the web/ directory
path: "web/"
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v1
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
.config/*
bin/*
.vs/*
.settings/*

### Java ###
*.class
Expand Down
11 changes: 11 additions & 0 deletions CITATION.cff
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
cff-version: "1.1.0"
authors:
-
family-names: Acharya
given-names: Piyush

date-released: 2022-10-10
doi: "10.1038/s41592-021-01101-x"
message: "If you use this software, please cite it using these metadata."
title: "A highly efficient, powerful, and feature-rich machine learning algorithm for analyzing DNA sequences"
version: "2.0.0"
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
</div>

<p align="center">
<img src="https://img.shields.io/badge/copyright-pending-blue" alt="Copyright"/>
<img src="https://img.shields.io/badge/copyright-2022-blue" alt="Copyright"/>
<img src="https://wakatime.com/badge/github/Verisimilitude11/DNAnalyzer.svg" alt="WakaTime"/>
<img src="https://img.shields.io/github/v/release/VERISIMILITUDE11/DNAnalyzer" alt="Releases"/>
<img src="https://img.shields.io/github/repo-size/Verisimilitude11/DNAnalyzer" alt="Repository Size"/>
Expand Down Expand Up @@ -97,7 +97,7 @@
</h3>
To build and run the DNAnalyzer, you need

* JDK 17 or greater
* JDK <a href="https://www.oracle.com/java/technologies/downloads/#jdk17-windows">17</a>
* A JAVA\_HOME environment variable pointing to your JDK, or the Java executable in your PATH
* <a href="https://gradle.org/install/">Gradle</a>

Expand Down Expand Up @@ -264,5 +264,5 @@ https://user-images.githubusercontent.com/27987685/194954560-5f470ecc-e733-4757-
</code>
</p>

### Copyright Pending © 2022 DNAnalyzer. Some rights reserved. This is an open source project.
### Copyright © 2022 Piyush Acharya & The DNAnalyzer Team. This is an open source project.

2 changes: 1 addition & 1 deletion src/main/java/DNAnalyzer/DnaAnalyzer.java
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,6 @@ public DnaAnalyzer printLongestProtein() {
}

private List<String> getProteins(String aminoAcid) {
return new ProteinFinder().getProtein(dna.getDna(), aminoAcid);
return ProteinFinder.getProtein(dna.getDna(), aminoAcid);
}
}
2 changes: 1 addition & 1 deletion src/main/java/DNAnalyzer/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public class Main {
*
* @throws InterruptedException
* @throws IOException
* @category User ExperienceF
* @category User Experience
*/
public static void clearTerminal() throws InterruptedException, IOException {
if (System.getProperty("os.name").contains("Windows")) { // if the os is Windows
Expand Down
15 changes: 8 additions & 7 deletions src/main/java/DNAnalyzer/codon/CodonFrame.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,14 @@ public int getMax() {

@Override
public boolean equals(final Object o) {
if (this == o)
return true;
if (!(o instanceof CodonFrame))
return false;
final CodonFrame that = (CodonFrame) o;
return getReadingFrame() == that.getReadingFrame() && getMin() == that.getMin() && getMax() == that.getMax()
&& getDna().equals(that.getDna());
boolean result = false;
if (this == o) {
result = true;
} else if (o instanceof final CodonFrame inputFrame) {
result = getReadingFrame() == inputFrame.getReadingFrame() && getMin() == inputFrame.getMin() && getMax() == inputFrame.getMax()
&& getDna().equals(inputFrame.getDna());
}
return result;
}

@Override
Expand Down
94 changes: 56 additions & 38 deletions src/main/java/DNAnalyzer/protein/ProteinFinder.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,77 +12,95 @@
package DNAnalyzer.protein;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import DNAnalyzer.codon.*;
import DNAnalyzer.aminoAcid.*;

import DNAnalyzer.aminoAcid.AminoAcidMapping;
import DNAnalyzer.aminoAcid.AminoAcidNames;
import DNAnalyzer.codon.CodonDataUtils;

/**
* Find proteins in a DNA sequence (contains the main algorithm).
*
* @author Piyush Acharya (@Verisimilitude11)
* @author Fernando Boaglio (@boaglio)
* @version 1.2.1
*/

public class ProteinFinder {
/**
* Amino acid list
*/

private final List<String> aminoAcidList;
/**
* protein list
* Utility classes should not have public constructors
*/
private final List<String> proteinList;

/**
* ProteinFinder default constructor to initialize aminoAcidList and proteinList
*/
public ProteinFinder() {
aminoAcidList = new ArrayList<>();
proteinList = new ArrayList<>();
private ProteinFinder() {
}

private static final int QT_NUCLEOTIDES = 3;

/**
* Gets proteins from dna and amino acid
*
* @param dna dna
* @param aminoAcid amino acid
* @param dna
* dna
* @param aminoAcid
* amino acid
* @return list of proteins
*/
public List<String> getProtein(final String dna, final String aminoAcid) {
this.aminoAcidList.addAll(CodonDataUtils.getAminoAcid(AminoAcidMapping.getAminoAcidMapping(aminoAcid)));
public static List<String> getProtein(final String dna, final String aminoAcid) {

int start_index;
int stop_index;
final List<String> stop = CodonDataUtils.getAminoAcid(AminoAcidNames.STOP);
List<String> aminoAcidList = new ArrayList<>();
List<String> proteinList = new ArrayList<>();

aminoAcidList.addAll(CodonDataUtils.getAminoAcid(AminoAcidMapping.getAminoAcidMapping(aminoAcid)));

int startIndex;
final List<String> stopCodonList = CodonDataUtils.getAminoAcid(AminoAcidNames.STOP);

// Outer loop loops through the start codons for the amino acids that the user
// entered.
// store the start index
// Inner loop loops through the stop that the user entered.
// store the stop_index
// if index is not -1 then store the substring of dna with start and stop index
// in the protein list
for (final String start_codon : this.aminoAcidList) {
start_index = dna.indexOf(start_codon.toLowerCase());
for (final String stop_codon : stop) {
stop_index = dna.indexOf(stop_codon.toLowerCase(), start_index + 3);
if ((start_index != -1) && (stop_index != -1)) {
this.proteinList.add(dna.substring(start_index, stop_index + 3).toUpperCase());
break;
}
}
for (final String startCodon : aminoAcidList) {
startIndex = dna.indexOf(startCodon.toLowerCase());
addProtein(dna, proteinList, startIndex, stopCodonList);
}

// if no proteins are found, return null
if (this.proteinList.isEmpty()) {
if (proteinList.isEmpty()) {
// Return null if no protein found in DNA sequence
System.out.println("No proteins found");
return null;
return Collections.emptyList();
}

// Return list of proteins found in the DNA sequence
return this.proteinList;
return proteinList;
}

/**
* Add protein to protein list
*
* @param dna
* @param proteinList
* @param startIndex
* @param stopCodonList
*/
private static void addProtein(final String dna, List<String> proteinList, int startIndex,
final List<String> stopCodonList) {

// Inner loop loops through the stop that the user entered.
// store the stopIndex
// if index is not -1 then store the substring of dna with start and stop index
// in the protein list
int stopIndex;
for (final String stopCodon : stopCodonList) {

stopIndex = dna.indexOf(stopCodon.toLowerCase(), startIndex + QT_NUCLEOTIDES);

if ((startIndex != -1) && (stopIndex != -1)) {
proteinList.add(dna.substring(startIndex, stopIndex + QT_NUCLEOTIDES).toUpperCase());
break;
}

}
}

}
2 changes: 1 addition & 1 deletion web/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ <h2 class="primary-dark">Features</h2>
<br>

<footer>
<p>Copyright © Piyush Acharya 2022. This is an open-source project.<br>
<p>Copyright © Piyush Acharya & The DNAnalyzer Team 2022. This is an open-source project.<br>
</p>
</footer>
<script src="./index.js"></script>
Expand Down

0 comments on commit 67a3587

Please sign in to comment.