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

Fix Deepsource issues for #422 #424

Merged
merged 5 commits into from
Oct 31, 2023
Merged
Changes from all commits
Commits
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
59 changes: 29 additions & 30 deletions src/test/java/DNAnalyzer/utils/core/ReadingFramesTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@

class ReadingFramesTest {

public static String testSequence = "gggggaggtggcgaggaagatgac";
public static String dnaSequenceWithLengthTwentyThree = "gggggaggtggcgaggaagatga";
public static String dnaSequenceWithLengthTwentyTwo = "gggggaggtggcgaggaagatg";
public static final String TEST_SEQUENCE = "gggggaggtggcgaggaagatgac";
public static final String DNA_SEQUENCE_WITH_LENGTH_TWENTY_THREE = "gggggaggtggcgaggaagatga";
public static final String DNA_SEQUENCE_WITH_LENGTH_TWENTY_TWO = "gggggaggtggcgaggaagatg";

/** These are the expected codon counts from .\assets\dna\real\brca1.fa using ReadingFrame 1 */
Map<String, Integer> brca1ExpectedFrame1CodonCounts =
private static final Map<String, Integer> BRCA_1_EXPECTED_FRAME_1_CODON_COUNTS =
Map.<String, Integer>ofEntries(
entry("GCG", 3),
entry("GCA", 76),
Expand Down Expand Up @@ -218,60 +218,60 @@ class ReadingFramesTest {
entry("TAA", 145));

@Test
public void calculateCodonStartIndicesFrame1Test() {
void calculateCodonStartIndicesFrame1Test() {
int[] expectedResult = {0, 3, 6, 9, 12, 15, 18, 21};
CodonFrame temp = new CodonFrame(testSequence, (short) 1, 1, 100);
CodonFrame temp = new CodonFrame(TEST_SEQUENCE, (short) 1, 1, 100);
ReadingFrames readingFrameTest = new ReadingFrames(temp);

int[] result = readingFrameTest.calculateCodonStartIndices(testSequence);
int[] result = readingFrameTest.calculateCodonStartIndices(TEST_SEQUENCE);

assertArrayEquals(expectedResult, result);
}

@Test
public void calculateCodonStartIndicesFrame2Test() {
void calculateCodonStartIndicesFrame2Test() {
int[] expectedResult = {1, 4, 7, 10, 13, 16, 19};
CodonFrame temp = new CodonFrame(testSequence, (short) 2, 1, 100);
CodonFrame temp = new CodonFrame(TEST_SEQUENCE, (short) 2, 1, 100);
ReadingFrames readingFrameTest = new ReadingFrames(temp);

int[] result = readingFrameTest.calculateCodonStartIndices(testSequence);
int[] result = readingFrameTest.calculateCodonStartIndices(TEST_SEQUENCE);

assertArrayEquals(expectedResult, result);
}

@Test
public void calculateCodonStartIndicesFrame3Test() {
void calculateCodonStartIndicesFrame3Test() {
int[] expectedResult = {2, 5, 8, 11, 14, 17, 20};
CodonFrame temp = new CodonFrame(testSequence, (short) 3, 1, 100);
CodonFrame temp = new CodonFrame(TEST_SEQUENCE, (short) 3, 1, 100);
ReadingFrames readingFrameTest = new ReadingFrames(temp);
int[] result = readingFrameTest.calculateCodonStartIndices(testSequence);
int[] result = readingFrameTest.calculateCodonStartIndices(TEST_SEQUENCE);
assertArrayEquals(expectedResult, result);
}

@Test
public void calculateCodonStartIndicesUsingDnaSequenceWithLengthTwentyThreeFrame1Test() {
void calculateCodonStartIndicesUsingDnaSequenceWithLengthTwentyThreeFrame1Test() {
int[] expectedResult = {0, 3, 6, 9, 12, 15, 18};
String testSequence = dnaSequenceWithLengthTwentyThree;
String testSequence = DNA_SEQUENCE_WITH_LENGTH_TWENTY_THREE;
CodonFrame temp = new CodonFrame(testSequence, (short) 1, 1, 100);
ReadingFrames readingFrameTest = new ReadingFrames(temp);
int[] result = readingFrameTest.calculateCodonStartIndices(testSequence);
assertArrayEquals(expectedResult, result);
}

@Test
public void calculateCodonStartIndicesUsingDnaSequenceWithLengthTwentyThreeFrame2Test() {
void calculateCodonStartIndicesUsingDnaSequenceWithLengthTwentyThreeFrame2Test() {
int[] expectedResult = {1, 4, 7, 10, 13, 16, 19};
String testSequence = dnaSequenceWithLengthTwentyThree;
String testSequence = DNA_SEQUENCE_WITH_LENGTH_TWENTY_THREE;
CodonFrame temp = new CodonFrame(testSequence, (short) 2, 1, 100);
ReadingFrames readingFrameTest = new ReadingFrames(temp);
int[] result = readingFrameTest.calculateCodonStartIndices(testSequence);
assertArrayEquals(expectedResult, result);
}

@Test
public void calculateCodonStartIndicesUsingDnaSequenceWithLengthTwentyThreeFrame3Test() {
void calculateCodonStartIndicesUsingDnaSequenceWithLengthTwentyThreeFrame3Test() {
int[] expectedResult = {2, 5, 8, 11, 14, 17, 20};
String testSequence = dnaSequenceWithLengthTwentyThree;
String testSequence = DNA_SEQUENCE_WITH_LENGTH_TWENTY_THREE;
CodonFrame temp = new CodonFrame(testSequence, (short) 3, 1, 100);
ReadingFrames readingFrameTest = new ReadingFrames(temp);
int[] result = readingFrameTest.calculateCodonStartIndices(testSequence);
Expand All @@ -280,51 +280,50 @@ public void calculateCodonStartIndicesUsingDnaSequenceWithLengthTwentyThreeFrame

// dnaSequenceWithLengthTwentyTwo
@Test
public void calculateCodonStartIndicesUsingDnaSequenceWithLengthTwentyTwoFrame1Test() {
void calculateCodonStartIndicesUsingDnaSequenceWithLengthTwentyTwoFrame1Test() {
int[] expectedResult = {0, 3, 6, 9, 12, 15, 18};
String testSequence = dnaSequenceWithLengthTwentyTwo;
String testSequence = DNA_SEQUENCE_WITH_LENGTH_TWENTY_TWO;
CodonFrame temp = new CodonFrame(testSequence, (short) 1, 1, 100);
ReadingFrames readingFrameTest = new ReadingFrames(temp);
int[] result = readingFrameTest.calculateCodonStartIndices(testSequence);
assertArrayEquals(expectedResult, result);
}

@Test
public void calculateCodonStartIndicesUsingDnaSequenceWithLengthTwentyTwoFrame2Test() {
void calculateCodonStartIndicesUsingDnaSequenceWithLengthTwentyTwoFrame2Test() {
int[] expectedResult = {1, 4, 7, 10, 13, 16, 19};
String testSequence = dnaSequenceWithLengthTwentyTwo;
String testSequence = DNA_SEQUENCE_WITH_LENGTH_TWENTY_TWO;
CodonFrame temp = new CodonFrame(testSequence, (short) 2, 1, 100);
ReadingFrames readingFrameTest = new ReadingFrames(temp);
int[] result = readingFrameTest.calculateCodonStartIndices(testSequence);
assertArrayEquals(expectedResult, result);
}

@Test
public void calculateCodonStartIndicesUsingDnaSequenceWithLengthTwentyTwoFrame3Test() {
void calculateCodonStartIndicesUsingDnaSequenceWithLengthTwentyTwoFrame3Test() {
int[] expectedResult = {2, 5, 8, 11, 14, 17};
String testSequence = dnaSequenceWithLengthTwentyTwo;
String testSequence = DNA_SEQUENCE_WITH_LENGTH_TWENTY_TWO;
CodonFrame temp = new CodonFrame(testSequence, (short) 3, 1, 100);
ReadingFrames readingFrameTest = new ReadingFrames(temp);
int[] result = readingFrameTest.calculateCodonStartIndices(testSequence);
assertArrayEquals(expectedResult, result);
}

@Test
public void buildCodonMapBrcaMethodsFrame1Tests() {
void buildCodonMapBrcaMethodsFrame1Tests() {
Path projectPath = Path.of("");
Path brcaPath = projectPath.resolve("assets/dna/real/brca1.fa");

String brcaDnaString = readFile(brcaPath.toFile());
Map<String, Integer> expectedResults = brca1ExpectedFrame1CodonCounts;
CodonFrame testCodonFrame = new CodonFrame(brcaDnaString, (short) 1, 1, 20000);
ReadingFrames testReadingFrame = new ReadingFrames(testCodonFrame);
Map<String, Integer> actualResults = testReadingFrame.getCodonCounts();

assertEquals(expectedResults, actualResults);
assertEquals(BRCA_1_EXPECTED_FRAME_1_CODON_COUNTS, actualResults);
}

@Test
public void buildCodonMapBrcaMethodsFrame2Tests() {
void buildCodonMapBrcaMethodsFrame2Tests() {
Path projectPath = Path.of("");
Path brcaPath = projectPath.resolve("assets/dna/real/brca1.fa");

Expand All @@ -338,7 +337,7 @@ public void buildCodonMapBrcaMethodsFrame2Tests() {
}

@Test
public void buildCodonMapBrcaMethodsFrame3Tests() {
void buildCodonMapBrcaMethodsFrame3Tests() {
Path projectPath = Path.of("");
Path brcaPath = projectPath.resolve("assets/dna/real/brca1.fa");

Expand Down