Skip to content

Commit

Permalink
Minor performance increase
Browse files Browse the repository at this point in the history
  • Loading branch information
VerisimilitudeX committed Aug 25, 2022
1 parent 3101384 commit 3c783dc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
14 changes: 7 additions & 7 deletions src/AminoAcidProperties.java
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import java.util.HashMap;

public class AminoAcidProperties {
private HashMap<String, Integer> codonCounts;
private String DNA;
private final HashMap<String, Integer> codonCounts;
private final String DNA;

public AminoAcidProperties(String DNA) {
codonCounts = new HashMap<String, Integer>();
codonCounts = new HashMap<>();
this.DNA = DNA;
}

private void buildCodonMap(int startReadingFrame, int start, int stop) {
private void buildCodonMap(int startReadingFrame) {
codonCounts.clear();
for (int i = start; i < DNA.length(); i += 3) {
for (int i = startReadingFrame; i < DNA.length(); i += 3) {
try {
if (codonCounts.containsKey(DNA.substring(i, i + 3))) {
codonCounts.put(DNA.substring(i, i + 3), codonCounts.get(DNA.substring(i, i + 3)) + 1);
Expand All @@ -24,8 +24,8 @@ private void buildCodonMap(int startReadingFrame, int start, int stop) {
}
}

public void printCodonCounts(int START_READING_FRAME, int start, int end) {
buildCodonMap(START_READING_FRAME, start, end);
public void printCodonCounts(int startReadingFrame, int start, int end) {
buildCodonMap(startReadingFrame);
int count = 0;
for (String codon : codonCounts.keySet()) {
if (codonCounts.get(codon) >= start && codonCounts.get(codon) <= end) {
Expand Down
6 changes: 2 additions & 4 deletions src/GeneInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ public class GeneInfo {
public void highGCContent(ArrayList<String> geneList) {
int count = 1;
// print the list of genes with the highest GC content
System.out.println();
System.out.println("High coverage regions: ");
System.out.println("\nHigh coverage regions: ");
System.out.println("----------------------------------------------------");

Properties p = new Properties();
Expand All @@ -32,7 +31,6 @@ public void longestGene(ArrayList<String> geneList) {
longestGene = gene;
}
}
System.out.println();
System.out.println("Longest gene (" + longestGene.length() + " nucleotides): " + longestGene);
System.out.println("\nLongest gene (" + longestGene.length() + " nucleotides): " + longestGene);
}
}

0 comments on commit 3c783dc

Please sign in to comment.