Skip to content

Commit

Permalink
Refactor Collection Implementations in Tests: Drop Guava for Java Native
Browse files Browse the repository at this point in the history
  • Loading branch information
iQuxLE committed Apr 29, 2024
1 parent eab9ebe commit 35240c6
Show file tree
Hide file tree
Showing 28 changed files with 345 additions and 323 deletions.
Original file line number Diff line number Diff line change
@@ -1,29 +1,30 @@
package org.monarchinitiative.gregor.mendel;

import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import org.monarchinitiative.gregor.pedigree.*;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

public class InheritanceCheckerMTSinglePersonTest extends MendelianCompatibilityCheckerTestBase {

private MendelianInheritanceChecker checker;
private List<GenotypeCalls> gcList;
private ImmutableMap<ModeOfInheritance, ImmutableList<GenotypeCalls>> result;
private Map<ModeOfInheritance, List<GenotypeCalls>> result;

@BeforeEach
public void setUp() throws Exception {
ImmutableList.Builder<PedPerson> individuals = new ImmutableList.Builder<PedPerson>();
individuals.add(new PedPerson("ped", "I.1", "0", "0", Sex.FEMALE, Disease.AFFECTED));
PedFileContents pedFileContents = new PedFileContents(new ImmutableList.Builder<String>().build(),
individuals.build());
List<PedPerson> individuals = List.of(
new PedPerson("ped", "I.1", "0", "0", Sex.FEMALE, Disease.AFFECTED)
);
PedFileContents pedFileContents = new PedFileContents(List.of(),
individuals);
this.pedigree = new Pedigree(pedFileContents, "ped");

this.names = ImmutableList.of("I.1");
this.names = List.of("I.1");

this.checker = new MendelianInheritanceChecker(this.pedigree);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
package org.monarchinitiative.gregor.mendel;

import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import org.monarchinitiative.gregor.pedigree.*;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

public class InheritanceCheckerMTSmallTest extends MendelianCompatibilityCheckerTestBase {

private MendelianInheritanceChecker checker;
private List<GenotypeCalls> gcList;
private ImmutableMap<ModeOfInheritance, ImmutableList<GenotypeCalls>> result;
private Map<ModeOfInheritance, List<GenotypeCalls>> result;

private Pedigree inconsistentMTpedigree;

@BeforeEach
public void setUp() throws Exception {
ImmutableList.Builder<PedPerson> individuals = new ImmutableList.Builder<PedPerson>();
List<PedPerson> individuals = new ArrayList<PedPerson>();
individuals.add(new PedPerson("ped", "I.1", "0", "0", Sex.MALE, Disease.UNAFFECTED)); // father
individuals.add(new PedPerson("ped", "I.2", "0", "0", Sex.FEMALE, Disease.AFFECTED)); // mother
individuals.add(new PedPerson("ped", "II.1", "I.1", "I.2", Sex.MALE, Disease.AFFECTED)); // son
individuals.add(new PedPerson("ped", "II.2", "I.1", "I.2", Sex.FEMALE, Disease.AFFECTED)); // daughter
PedFileContents pedFileContents = new PedFileContents(new ImmutableList.Builder<String>().build(),
individuals.build());
PedFileContents pedFileContents = new PedFileContents(new ArrayList<String>(),
individuals);
this.pedigree = new Pedigree(pedFileContents, "ped");

this.names = ImmutableList.of("I.1", "I.2", "II.1", "II.2");
this.names = List.of("I.1", "I.2", "II.1", "II.2");

this.checker = new MendelianInheritanceChecker(this.pedigree);

Expand All @@ -38,13 +38,13 @@ public void setUp() throws Exception {
* same as above but father is transmitting mitochrondrial mutation, which is
* impossible
*/
ImmutableList.Builder<PedPerson> individuals2 = new ImmutableList.Builder<PedPerson>();
List<PedPerson> individuals2 = new ArrayList<PedPerson>();
individuals2.add(new PedPerson("ped2", "I.1", "0", "0", Sex.MALE, Disease.AFFECTED)); // father
individuals2.add(new PedPerson("ped2", "I.2", "0", "0", Sex.FEMALE, Disease.UNAFFECTED)); // mother
individuals2.add(new PedPerson("ped2", "II.1", "I.1", "I.2", Sex.MALE, Disease.AFFECTED)); // son
individuals2.add(new PedPerson("ped2", "II.2", "I.1", "I.2", Sex.FEMALE, Disease.AFFECTED)); // daughter
PedFileContents pedFileContents2 = new PedFileContents(new ImmutableList.Builder<String>().build(),
individuals2.build());
PedFileContents pedFileContents2 = new PedFileContents(new ArrayList<String>(),
individuals2);
this.inconsistentMTpedigree = new Pedigree(pedFileContents2, "ped2");
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,41 +1,42 @@
package org.monarchinitiative.gregor.mendel;

import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import org.monarchinitiative.gregor.pedigree.*;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

public class MendelianCompatibilityCheckerADLargeTest extends MendelianCompatibilityCheckerTestBase {

MendelianInheritanceChecker checker;
List<GenotypeCalls> gcList;
ImmutableMap<ModeOfInheritance, ImmutableList<GenotypeCalls>> result;
Map<ModeOfInheritance, List<GenotypeCalls>> result;

@BeforeEach
public void setUp() throws Exception {
ImmutableList.Builder<PedPerson> individuals = new ImmutableList.Builder<PedPerson>();
individuals.add(new PedPerson("ped", "I.1", "0", "0", Sex.MALE, Disease.UNAFFECTED)); // grandfather
individuals.add(new PedPerson("ped", "I.2", "0", "0", Sex.FEMALE, Disease.UNAFFECTED)); // grandmother
individuals.add(new PedPerson("ped", "II.1", "I.1", "I.2", Sex.MALE, Disease.UNAFFECTED)); // p1
individuals.add(new PedPerson("ped", "II.2", "I.1", "I.2", Sex.MALE, Disease.AFFECTED)); // p2
individuals.add(new PedPerson("ped", "II.3", "I.1", "I.2", Sex.FEMALE, Disease.UNAFFECTED)); // p3
individuals.add(new PedPerson("ped", "II.4", "I.1", "I.2", Sex.FEMALE, Disease.AFFECTED)); // p4
individuals.add(new PedPerson("ped", "II.5", "I.1", "I.2", Sex.UNKNOWN, Disease.UNKNOWN)); // p5
individuals.add(new PedPerson("ped", "III.1", "II.1", "0", Sex.FEMALE, Disease.UNAFFECTED)); // c1
individuals.add(new PedPerson("ped", "III.2", "II.1", "0", Sex.MALE, Disease.UNAFFECTED)); // c2
individuals.add(new PedPerson("ped", "III.3", "II.2", "0", Sex.MALE, Disease.AFFECTED)); // c3
individuals.add(new PedPerson("ped", "III.4", "II.2", "0", Sex.FEMALE, Disease.UNAFFECTED)); // c4
individuals.add(new PedPerson("ped", "III.5", "0", "II.3", Sex.FEMALE, Disease.UNAFFECTED)); // c5
individuals.add(new PedPerson("ped", "III.6", "0", "II.4", Sex.MALE, Disease.AFFECTED)); // c6
PedFileContents pedFileContents = new PedFileContents(new ImmutableList.Builder<String>().build(),
individuals.build());
List<PedPerson> individuals = List.of(
new PedPerson("ped", "I.1", "0", "0", Sex.MALE, Disease.UNAFFECTED), // grandfather
new PedPerson("ped", "I.2", "0", "0", Sex.FEMALE, Disease.UNAFFECTED), // grandmother
new PedPerson("ped", "II.1", "I.1", "I.2", Sex.MALE, Disease.UNAFFECTED), // p1
new PedPerson("ped", "II.2", "I.1", "I.2", Sex.MALE, Disease.AFFECTED), // p2
new PedPerson("ped", "II.3", "I.1", "I.2", Sex.FEMALE, Disease.UNAFFECTED), // p3
new PedPerson("ped", "II.4", "I.1", "I.2", Sex.FEMALE, Disease.AFFECTED), // p4
new PedPerson("ped", "II.5", "I.1", "I.2", Sex.UNKNOWN, Disease.UNKNOWN), // p5
new PedPerson("ped", "III.1", "II.1", "0", Sex.FEMALE, Disease.UNAFFECTED), // c1
new PedPerson("ped", "III.2", "II.1", "0", Sex.MALE, Disease.UNAFFECTED), // c2
new PedPerson("ped", "III.3", "II.2", "0", Sex.MALE, Disease.AFFECTED), // c3
new PedPerson("ped", "III.4", "II.2", "0", Sex.FEMALE, Disease.UNAFFECTED), // c4
new PedPerson("ped", "III.5", "0", "II.3", Sex.FEMALE, Disease.UNAFFECTED), // c5
new PedPerson("ped", "III.6", "0", "II.4", Sex.MALE, Disease.AFFECTED) // c6
);
PedFileContents pedFileContents = new PedFileContents(List.of(),
individuals);
this.pedigree = new Pedigree(pedFileContents, "ped");

this.names = ImmutableList.of("I.1", "I.2", "II.1", "II.2", "II.3", "II.4", "II.5", "III.1", "III.2", "III.3",
this.names = List.of("I.1", "I.2", "II.1", "II.2", "II.3", "II.4", "II.5", "III.1", "III.2", "III.3",
"III.4", "III.5", "III.6");

this.checker = new MendelianInheritanceChecker(this.pedigree);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,42 +1,42 @@
package org.monarchinitiative.gregor.mendel;

import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import org.monarchinitiative.gregor.pedigree.*;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

public class MendelianCompatibilityCheckerADMediumTest extends MendelianCompatibilityCheckerTestBase {

MendelianInheritanceChecker checker;
List<GenotypeCalls> gcList;
ImmutableMap<ModeOfInheritance, ImmutableList<GenotypeCalls>> result;
Map<ModeOfInheritance, List<GenotypeCalls>> result;

@BeforeEach
public void setUp() throws Exception {
ImmutableList.Builder<PedPerson> individuals = new ImmutableList.Builder<PedPerson>();
individuals.add(new PedPerson("ped", "I.1", "0", "0", Sex.MALE, Disease.UNAFFECTED)); // grandfather
individuals.add(new PedPerson("ped", "I.2", "0", "0", Sex.FEMALE, Disease.UNAFFECTED)); // grandmother
individuals.add(new PedPerson("ped", "II.1", "I.1", "I.2", Sex.MALE, Disease.UNAFFECTED)); // uncle
individuals.add(new PedPerson("ped", "II.2", "I.1", "I.2", Sex.MALE, Disease.AFFECTED)); // father
individuals.add(new PedPerson("ped", "II.3", "0", "0", Sex.FEMALE, Disease.UNAFFECTED)); // mother
individuals.add(new PedPerson("ped", "III.1", "II.2", "II.3", Sex.FEMALE, Disease.AFFECTED)); // daughter
individuals.add(new PedPerson("ped", "III.2", "II.2", "II.3", Sex.MALE, Disease.UNAFFECTED)); // son
PedFileContents pedFileContents = new PedFileContents(new ImmutableList.Builder<String>().build(),
individuals.build());
List<PedPerson> individuals = List.of(
new PedPerson("ped", "I.1", "0", "0", Sex.MALE, Disease.UNAFFECTED), // grandfather
new PedPerson("ped", "I.2", "0", "0", Sex.FEMALE, Disease.UNAFFECTED), // grandmother
new PedPerson("ped", "II.1", "I.1", "I.2", Sex.MALE, Disease.UNAFFECTED), // uncle
new PedPerson("ped", "II.2", "I.1", "I.2", Sex.MALE, Disease.AFFECTED), // father
new PedPerson("ped", "II.3", "0", "0", Sex.FEMALE, Disease.UNAFFECTED), // mother
new PedPerson("ped", "III.1", "II.2", "II.3", Sex.FEMALE, Disease.AFFECTED), // daughter
new PedPerson("ped", "III.2", "II.2", "II.3", Sex.MALE, Disease.UNAFFECTED) // son
);
PedFileContents pedFileContents = new PedFileContents(List.of(), individuals);
this.pedigree = new Pedigree(pedFileContents, "ped");

this.names = ImmutableList.of("I.1", "I.2", "II.1", "II.2", "II.3", "III.1", "III.2");

this.names = List.of("I.1", "I.2", "II.1", "II.2", "II.3", "III.1", "III.2");
this.checker = new MendelianInheritanceChecker(this.pedigree);

this.result = null;
this.gcList = null;
}


@Test
public void testSizeOfPedigree() {
Assertions.assertEquals(7, pedigree.getMembers().size());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,28 +1,29 @@
package org.monarchinitiative.gregor.mendel;

import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import org.monarchinitiative.gregor.pedigree.*;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

public class MendelianCompatibilityCheckerADSingletonTest extends MendelianCompatibilityCheckerTestBase {

MendelianInheritanceChecker checker;
List<GenotypeCalls> gcList;
ImmutableMap<ModeOfInheritance, ImmutableList<GenotypeCalls>> result;
Map<ModeOfInheritance, List<GenotypeCalls>> result;

@BeforeEach
public void setUp() throws Exception {
ImmutableList.Builder<PedPerson> individuals = new ImmutableList.Builder<PedPerson>();
individuals.add(new PedPerson("ped", "I.1", "0", "0", Sex.MALE, Disease.AFFECTED));
PedFileContents pedFileContents = new PedFileContents(new ImmutableList.Builder<String>().build(),
individuals.build());
List<PedPerson> individuals = List.of(
new PedPerson("ped", "I.1", "0", "0", Sex.MALE, Disease.AFFECTED)
);
PedFileContents pedFileContents = new PedFileContents(List.of(),
individuals);
this.pedigree = new Pedigree(pedFileContents, "ped");
this.names = ImmutableList.of("I.1");
this.names = List.of("I.1");

this.checker = new MendelianInheritanceChecker(this.pedigree);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
package org.monarchinitiative.gregor.mendel;

import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import org.monarchinitiative.gregor.pedigree.*;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import java.util.List;
import java.util.Map;

public class MendelianCompatibilityCheckerADSmallTest extends MendelianCompatibilityCheckerTestBase {

MendelianInheritanceChecker checker;
List<GenotypeCalls> gcList;
ImmutableMap<ModeOfInheritance, ImmutableList<GenotypeCalls>> result;
Map<ModeOfInheritance, List<GenotypeCalls>> result;

@BeforeEach
public void setUp() throws Exception {
ImmutableList.Builder<PedPerson> individuals = new ImmutableList.Builder<PedPerson>();
individuals.add(new PedPerson("ped", "I.1", "0", "0", Sex.MALE, Disease.AFFECTED)); // father
individuals.add(new PedPerson("ped", "I.2", "0", "0", Sex.FEMALE, Disease.UNAFFECTED)); // mother
individuals.add(new PedPerson("ped", "II.1", "I.1", "I.2", Sex.MALE, Disease.AFFECTED)); // son
individuals.add(new PedPerson("ped", "II.2", "I.1", "I.2", Sex.FEMALE, Disease.UNAFFECTED)); // daughter
PedFileContents pedFileContents = new PedFileContents(new ImmutableList.Builder<String>().build(),
individuals.build());
List<PedPerson> individuals = List.of(
new PedPerson("ped", "I.1", "0", "0", Sex.MALE, Disease.AFFECTED), // father
new PedPerson("ped", "I.2", "0", "0", Sex.FEMALE, Disease.UNAFFECTED), // mother
new PedPerson("ped", "II.1", "I.1", "I.2", Sex.MALE, Disease.AFFECTED), // son
new PedPerson("ped", "II.2", "I.1", "I.2", Sex.FEMALE, Disease.UNAFFECTED) // daughter
);
PedFileContents pedFileContents = new PedFileContents(List.of(),
individuals);
this.pedigree = new Pedigree(pedFileContents, "ped");

this.names = ImmutableList.of("I.1", "I.2", "II.1", "II.2");
this.names = List.of("I.1", "I.2", "II.1", "II.2");

this.checker = new MendelianInheritanceChecker(this.pedigree);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,30 +1,29 @@
package org.monarchinitiative.gregor.mendel;

import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import org.monarchinitiative.gregor.pedigree.*;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import java.util.List;
import java.util.Map;

public class MendelianCompatibilityCheckerADVerySmallTest extends MendelianCompatibilityCheckerTestBase {

MendelianInheritanceChecker checker;
List<GenotypeCalls> gcList;
ImmutableMap<ModeOfInheritance, ImmutableList<GenotypeCalls>> result;
Map<ModeOfInheritance, List<GenotypeCalls>> result;

@BeforeEach
public void setUp() throws Exception {
ImmutableList.Builder<PedPerson> individuals = new ImmutableList.Builder<PedPerson>();
individuals.add(new PedPerson("ped", "I.1", "0", "0", Sex.MALE, Disease.UNAFFECTED)); // father
individuals.add(new PedPerson("ped", "II.1", "I.1", "0", Sex.MALE, Disease.AFFECTED)); // son
PedFileContents pedFileContents = new PedFileContents(new ImmutableList.Builder<String>().build(),
individuals.build());
List<PedPerson> individuals = List.of(
new PedPerson("ped", "I.1", "0", "0", Sex.MALE, Disease.UNAFFECTED), // father
new PedPerson("ped", "II.1", "I.1", "0", Sex.MALE, Disease.AFFECTED)); // son
PedFileContents pedFileContents = new PedFileContents(List.of(),
individuals);
this.pedigree = new Pedigree(pedFileContents, "ped");

this.names = ImmutableList.of("I.1", "II.1");
this.names = List.of("I.1", "II.1");

this.checker = new MendelianInheritanceChecker(this.pedigree);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,35 +1,36 @@
package org.monarchinitiative.gregor.mendel;

import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import org.monarchinitiative.gregor.pedigree.*;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

public class MendelianCompatibilityCheckerARLarge2Test extends MendelianCompatibilityCheckerTestBase {

MendelianInheritanceChecker checker;
List<GenotypeCalls> gcList;
ImmutableMap<ModeOfInheritance, ImmutableList<GenotypeCalls>> result;
Map<ModeOfInheritance, List<GenotypeCalls>> result;

@BeforeEach
public void setUp() throws Exception {
ImmutableList.Builder<PedPerson> individuals = new ImmutableList.Builder<PedPerson>();
individuals.add(new PedPerson("ped", "I.1", "0", "0", Sex.MALE, Disease.UNAFFECTED)); // grandgrandfather
individuals.add(new PedPerson("ped", "I.2", "0", "0", Sex.FEMALE, Disease.UNAFFECTED)); // grandgrandmother
individuals.add(new PedPerson("ped", "II.1", "I.1", "I.2", Sex.FEMALE, Disease.AFFECTED)); // parent1
individuals.add(new PedPerson("ped", "II.2", "I.1", "I.2", Sex.MALE, Disease.UNAFFECTED)); // parent2
individuals.add(new PedPerson("ped", "II.3", "0", "0", Sex.FEMALE, Disease.UNAFFECTED)); // parent3
individuals.add(new PedPerson("ped", "III.1", "II.2", "II.3", Sex.MALE, Disease.AFFECTED)); // child1
individuals.add(new PedPerson("ped", "III.2", "II.2", "II.3", Sex.FEMALE, Disease.UNAFFECTED)); // child2
PedFileContents pedFileContents = new PedFileContents(new ImmutableList.Builder<String>().build(),
individuals.build());
List<PedPerson> individuals = List.of(
new PedPerson("ped", "I.1", "0", "0", Sex.MALE, Disease.UNAFFECTED), // grandgrandfather
new PedPerson("ped", "I.2", "0", "0", Sex.FEMALE, Disease.UNAFFECTED), // grandgrandmother
new PedPerson("ped", "II.1", "I.1", "I.2", Sex.FEMALE, Disease.AFFECTED), // parent1
new PedPerson("ped", "II.2", "I.1", "I.2", Sex.MALE, Disease.UNAFFECTED), // parent2
new PedPerson("ped", "II.3", "0", "0", Sex.FEMALE, Disease.UNAFFECTED), // parent3
new PedPerson("ped", "III.1", "II.2", "II.3", Sex.MALE, Disease.AFFECTED), // child1
new PedPerson("ped", "III.2", "II.2", "II.3", Sex.FEMALE, Disease.UNAFFECTED) // child2
);
PedFileContents pedFileContents = new PedFileContents(List.of(),
individuals);
this.pedigree = new Pedigree(pedFileContents, "ped");

this.names = ImmutableList.of("I.1", "I.2", "II.1", "II.2", "II.3", "III.1", "III.2");
this.names = List.of("I.1", "I.2", "II.1", "II.2", "II.3", "III.1", "III.2");

this.checker = new MendelianInheritanceChecker(this.pedigree);

Expand Down
Loading

0 comments on commit 35240c6

Please sign in to comment.