method2testcases
stringlengths 118
6.63k
|
---|
### Question:
MapCache implements Cache<K, V> { @Override public MapCache<K, V> set(K key, V value) { if (value == null) { return this; } validateKey(key); mCache.put(key, value); return this; } <O extends MapCache.Options> MapCache(O opts); @Override V get(K key); @Override MapCache<K, V> set(K key, V value); static final float DEFAULT_LOAD_FACTOR; }### Answer:
@Test public void testNullNoOp() { gimmeCacheOfOne().set("key", null); }
|
### Question:
AzureFunctionsPlugin implements Plugin<Project> { public void apply(Project project) { AzureFunctionsExtension azureFunctionsExtension = new AzureFunctionsExtension(); project.getExtensions().add(AZURE_FUNCTIONS, azureFunctionsExtension); } void apply(Project project); static final String AZURE_FUNCTIONS; }### Answer:
@Test public void greeterPluginAddsGreetingTaskToProject() { Project project = ProjectBuilder.builder().build(); project.getPluginManager().apply("lenala.azure.azurefunctions"); assertTrue(project.getTasks().findByPath("package") instanceof PackageTask); }
|
### Question:
AzureWebappPlugin implements Plugin<Project> { public void apply(Project project) { AzureWebAppExtension azureWebAppExtension = new AzureWebAppExtension(project); project.getExtensions().add(WEBAPP_EXTENSION_NAME, azureWebAppExtension); project.getTasks().create(DeployTask.TASK_NAME, DeployTask.class, (task) -> { task.setAzureWebAppExtension(azureWebAppExtension); }); } void apply(Project project); }### Answer:
@Test public void greeterPluginAddsGreetingTaskToProject() { Project project = ProjectBuilder.builder().build(); project.getPluginManager().apply("lenala.azure.azurewebapp"); assertTrue(project.getTasks().findByPath("azureWebappDeploy") instanceof DeployTask); }
|
### Question:
ProteinSubstitution extends ProteinChange { @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; ProteinSubstitution other = (ProteinSubstitution) obj; if (location == null) { if (other.location != null) return false; } else if (!location.equals(other.location)) return false; if (targetAA == null) { if (other.targetAA != null) return false; } else if (!targetAA.equals(other.targetAA)) return false; return true; } ProteinSubstitution(boolean onlyPredicted, ProteinPointLocation location, String targetAA); static ProteinSubstitution build(boolean onlyPredicted, String sourceAA, int pos, String targetAA); static ProteinSubstitution buildWithOffset(boolean onlyPredicted, String sourceAA, int pos, int offset,
String targetAA); static ProteinSubstitution buildDownstreamOfTerminal(boolean onlyPredicted, String sourceAA, int pos,
String targetAA); ProteinPointLocation getLocation(); String getTargetAA(); @Override String toHGVSString(AminoAcidCode code); @Override String toString(); @Override int hashCode(); @Override boolean equals(Object obj); @Override ProteinChange withOnlyPredicted(boolean onlyPredicted); }### Answer:
@Test public void testEquals() { Assert.assertTrue(sub1.equals(sub2)); Assert.assertTrue(sub2.equals(sub1)); Assert.assertFalse(sub1.equals(sub3)); Assert.assertFalse(sub3.equals(sub1)); }
|
### Question:
ProteinExtension extends ProteinChange { public static ProteinExtension buildWithoutTerminal(boolean onlyPredicted, String wtAA, int pos, String targetAA) { return new ProteinExtension(onlyPredicted, ProteinPointLocation.build(wtAA, pos), targetAA, LEN_NO_TER); } ProteinExtension(boolean onlyPredicted, ProteinPointLocation position, String targetAA, int shift); static ProteinExtension build(boolean onlyPredicted, String wtAA, int pos, String targetAA, int shift); static ProteinExtension build(boolean onlyPredicted, ProteinPointLocation position, String targetAA,
int shift); static ProteinExtension buildWithoutTerminal(boolean onlyPredicted, String wtAA, int pos, String targetAA); static ProteinExtension buildWithoutTerminal(boolean onlyPredicted, ProteinPointLocation position,
String targetAA); ProteinPointLocation getPosition(); String getTargetAA(); int getShift(); boolean isNoTerminalExtension(); @Override String toHGVSString(AminoAcidCode code); @Override String toString(); @Override int hashCode(); @Override boolean equals(Object obj); @Override ProteinChange withOnlyPredicted(boolean onlyPredicted); static final int LEN_NO_TER; }### Answer:
@Test public void testBuildNoTerExtension() { Assert.assertEquals(noTerExtension, ProteinExtension.buildWithoutTerminal(false, position, "T")); }
|
### Question:
ProteinExtension extends ProteinChange { @Override public String toHGVSString(AminoAcidCode code) { String targetAA = this.targetAA; if (code == AminoAcidCode.THREE_LETTER) targetAA = Translator.getTranslator().toLong(targetAA); if (isNoTerminalExtension()) return wrapIfOnlyPredicted(Joiner.on("").join(position.toHGVSString(code), targetAA, "ext*?")); else return wrapIfOnlyPredicted(Joiner.on("").join(position.toHGVSString(code), targetAA, "ext*", shift)); } ProteinExtension(boolean onlyPredicted, ProteinPointLocation position, String targetAA, int shift); static ProteinExtension build(boolean onlyPredicted, String wtAA, int pos, String targetAA, int shift); static ProteinExtension build(boolean onlyPredicted, ProteinPointLocation position, String targetAA,
int shift); static ProteinExtension buildWithoutTerminal(boolean onlyPredicted, String wtAA, int pos, String targetAA); static ProteinExtension buildWithoutTerminal(boolean onlyPredicted, ProteinPointLocation position,
String targetAA); ProteinPointLocation getPosition(); String getTargetAA(); int getShift(); boolean isNoTerminalExtension(); @Override String toHGVSString(AminoAcidCode code); @Override String toString(); @Override int hashCode(); @Override boolean equals(Object obj); @Override ProteinChange withOnlyPredicted(boolean onlyPredicted); static final int LEN_NO_TER; }### Answer:
@Test public void testNormalExtensionToHGVSString() { Assert.assertEquals("A124Text*23", normalExtension.toHGVSString()); Assert.assertEquals("Ala124Thrext*23", normalExtension.toHGVSString(AminoAcidCode.THREE_LETTER)); Assert.assertEquals("A124Text*23", normalExtension.toHGVSString(AminoAcidCode.ONE_LETTER)); }
@Test public void testNoTerExtensionToHGVSString() { Assert.assertEquals("A124Text*?", noTerExtension.toHGVSString()); Assert.assertEquals("Ala124Thrext*?", noTerExtension.toHGVSString(AminoAcidCode.THREE_LETTER)); Assert.assertEquals("A124Text*?", noTerExtension.toHGVSString(AminoAcidCode.ONE_LETTER)); }
|
### Question:
ProteinRange implements ConvertibleToHGVSString { @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; ProteinRange other = (ProteinRange) obj; if (first == null) { if (other.first != null) return false; } else if (!first.equals(other.first)) return false; if (last == null) { if (other.last != null) return false; } else if (!last.equals(other.last)) return false; return true; } ProteinRange(ProteinPointLocation first, ProteinPointLocation last); static ProteinRange build(String firstAA, int first, String lastAA, int last); static ProteinRange buildWithOffset(String firstAA, int first, int firstOffset, String lastAA, int last,
int lastOffset); static ProteinRange buildDownstreamOfTerminal(String firstAA, int first, String lastAA, int last); ProteinPointLocation getFirst(); ProteinPointLocation getLast(); int length(); @Override String toHGVSString(); @Override String toHGVSString(AminoAcidCode code); @Override String toString(); @Override int hashCode(); @Override boolean equals(Object obj); }### Answer:
@Test public void testEquals() { Assert.assertEquals(firstRange, firstRange2); Assert.assertNotEquals(secondRange, firstRange); }
|
### Question:
ProteinRange implements ConvertibleToHGVSString { @Override public String toHGVSString() { return toHGVSString(AminoAcidCode.THREE_LETTER); } ProteinRange(ProteinPointLocation first, ProteinPointLocation last); static ProteinRange build(String firstAA, int first, String lastAA, int last); static ProteinRange buildWithOffset(String firstAA, int first, int firstOffset, String lastAA, int last,
int lastOffset); static ProteinRange buildDownstreamOfTerminal(String firstAA, int first, String lastAA, int last); ProteinPointLocation getFirst(); ProteinPointLocation getLast(); int length(); @Override String toHGVSString(); @Override String toHGVSString(AminoAcidCode code); @Override String toString(); @Override int hashCode(); @Override boolean equals(Object obj); }### Answer:
@Test public void testToHGVSStringWithOffset() { Assert.assertEquals("Gly126-1_Thr302-1", offsetRange.toHGVSString()); }
@Test public void testToHGVSStringDownstreamOfTerminal() { Assert.assertEquals("Gly*126_Thr*302", downstreamOfTerminalRange.toHGVSString()); }
|
### Question:
GenomicNucleotideChangeBuilder { public NucleotideChange build() { final String ref; final String alt; if (variant.getGenomeInterval().getStrand() == Strand.FWD) { ref = variant.getRef(); alt = variant.getAlt(); } else { ref = DNAUtils.reverseComplement(variant.getRef()); alt = DNAUtils.reverseComplement(variant.getAlt()); } GenomePosition position = variant.getGenomePos().withStrand(Strand.FWD); final int beginPos = position.getPos(); if (ref.length() == 1 && alt.length() == 1) return NucleotideSubstitution.build(false, beginPos, ref, alt); if (ref.length() == 0) return NucleotideInsertion.buildWithSequence(false, beginPos - 1, beginPos, alt); else if (alt.length() == 0) return NucleotideDeletion.buildWithSequence(false, beginPos, beginPos + ref.length() - 1, ref); else if (ref.length() != alt.length()) return NucleotideIndel.buildWithSequence(false, beginPos, beginPos + ref.length() - 1, ref, alt); StringBuilder altRC = new StringBuilder(alt).reverse(); for (int i = 0; i < altRC.length(); ++i) if (altRC.charAt(i) == 'A') altRC.setCharAt(i, 'T'); else if (altRC.charAt(i) == 'T') altRC.setCharAt(i, 'A'); else if (altRC.charAt(i) == 'C') altRC.setCharAt(i, 'G'); else if (altRC.charAt(i) == 'G') altRC.setCharAt(i, 'C'); if (ref.length() == alt.length() && ref.equals(altRC.toString())) return NucleotideInversion.buildWithoutSeqDescription(false, beginPos, beginPos + ref.length() - 1); else return NucleotideIndel.buildWithSequence(false, beginPos, beginPos + ref.length() - 1, ref, alt); } GenomicNucleotideChangeBuilder(GenomeVariant variant); GenomeVariant getVariant(); NucleotideChange build(); }### Answer:
@Test public void testInsertion() { Assert.assertEquals("100_101insCGAT", new GenomicNucleotideChangeBuilder(varIns).build().toHGVSString()); }
@Test public void testDeletion() { Assert.assertEquals("101_104delCGAT", new GenomicNucleotideChangeBuilder(varDel).build().toHGVSString()); }
@Test public void testSNV() { Assert.assertEquals("101C>T", new GenomicNucleotideChangeBuilder(varSNV).build().toHGVSString()); }
@Test public void testSubstitution() { Assert.assertEquals("101_103delCGAinsTTT", new GenomicNucleotideChangeBuilder(varSub).build().toHGVSString()); }
@Test public void testInversion() { Assert.assertEquals("101_104inv", new GenomicNucleotideChangeBuilder(varInv).build().toHGVSString()); }
|
### Question:
PedPerson { public boolean isFounder() { return ("0".equals(father) && "0".equals(mother)); } PedPerson(String pedigree, String name, String father, String mother, Sex sex, Disease disease,
Collection<String> extraFields); PedPerson(String pedigree, String name, String father, String mother, Sex sex, Disease disease); String getPedigree(); String getName(); String getFather(); String getMother(); Sex getSex(); Disease getDisease(); ImmutableList<String> getExtraFields(); boolean isFounder(); @Override String toString(); @Override int hashCode(); @Override boolean equals(Object obj); }### Answer:
@Test public void testIsFounderTrue() { PedPerson person = new PedPerson("fam", "name", "0", "0", Sex.MALE, Disease.AFFECTED); Assert.assertTrue(person.isFounder()); }
@Test public void testIsFounderFalse() { PedPerson person = new PedPerson("fam", "name", "father", "0", Sex.MALE, Disease.AFFECTED); Assert.assertFalse(person.isFounder()); }
|
### Question:
PedFileWriter { public void write(PedFileContents contents) throws IOException { FileOutputStream fos = new FileOutputStream(file); BufferedOutputStream stream = new BufferedOutputStream(fos); write(contents, stream); stream.close(); fos.close(); } PedFileWriter(File file); void write(PedFileContents contents); static void write(PedFileContents contents, OutputStream stream); }### Answer:
@Test public void testWrite() throws IOException { ImmutableList.Builder<PedPerson> individuals = new ImmutableList.Builder<PedPerson>(); individuals.add(new PedPerson("fam", "father", "0", "0", Sex.MALE, Disease.UNKNOWN)); individuals.add(new PedPerson("fam", "mother", "0", "0", Sex.FEMALE, Disease.UNKNOWN)); individuals.add(new PedPerson("fam", "son", "father", "mother", Sex.MALE, Disease.UNKNOWN)); individuals.add(new PedPerson("fam", "daughter", "father", "mother", Sex.FEMALE, Disease.UNKNOWN)); PedFileContents pedFileContents = new PedFileContents(new ImmutableList.Builder<String>().build(), individuals.build()); PedFileWriter writer = new PedFileWriter(tmpFile); writer.write(pedFileContents); String fileContents = Files.asCharSource(tmpFile, Charsets.UTF_8).read(); StringBuilder expectedContents = new StringBuilder(); expectedContents.append("#PEDIGREE\tNAME\tFATHER\tMOTHER\tSEX\tDISEASE\n"); expectedContents.append("fam\tfather\t0\t0\t1\t0\n"); expectedContents.append("fam\tmother\t0\t0\t2\t0\n"); expectedContents.append("fam\tson\tfather\tmother\t1\t0\n"); expectedContents.append("fam\tdaughter\tfather\tmother\t2\t0\n"); Assert.assertEquals(expectedContents.toString(), fileContents); }
|
### Question:
PedigreeQueryDecorator { public boolean isParentOfAffected(Person person) { for (Person member : pedigree.getMembers()) if (member.getFather() == person || member.getMother() == person) return true; return false; } PedigreeQueryDecorator(Pedigree pedigree); Pedigree getPedigree(); boolean isParentOfAffected(Person person); ImmutableSet<String> getUnaffectedNames(); ImmutableSet<String> getParentNames(); ImmutableSet<String> getAffectedFemaleParentNames(); ImmutableSet<String> getAffectedMaleParentNames(); ImmutableList<Person> getParents(); int getNumberOfParents(); int getNumberOfAffecteds(); int getNumberOfUnaffecteds(); ImmutableMap<Person, ImmutableList<Person>> buildSiblings(); }### Answer:
@Test public void testIsParentOfAffected() { Assert.assertTrue(decorator.isParentOfAffected(pedigree.getMembers().get(0))); Assert.assertTrue(decorator.isParentOfAffected(pedigree.getMembers().get(1))); Assert.assertFalse(decorator.isParentOfAffected(pedigree.getMembers().get(2))); Assert.assertFalse(decorator.isParentOfAffected(pedigree.getMembers().get(3))); }
|
### Question:
PedigreeQueryDecorator { public ImmutableSet<String> getUnaffectedNames() { ImmutableSet.Builder<String> resultNames = new ImmutableSet.Builder<String>(); for (Person member : pedigree.getMembers()) if (member.getDisease() == Disease.UNAFFECTED) resultNames.add(member.getName()); return resultNames.build(); } PedigreeQueryDecorator(Pedigree pedigree); Pedigree getPedigree(); boolean isParentOfAffected(Person person); ImmutableSet<String> getUnaffectedNames(); ImmutableSet<String> getParentNames(); ImmutableSet<String> getAffectedFemaleParentNames(); ImmutableSet<String> getAffectedMaleParentNames(); ImmutableList<Person> getParents(); int getNumberOfParents(); int getNumberOfAffecteds(); int getNumberOfUnaffecteds(); ImmutableMap<Person, ImmutableList<Person>> buildSiblings(); }### Answer:
@Test public void testGetUnaffectedNames() { Assert.assertEquals(ImmutableSet.of("father"), decorator.getUnaffectedNames()); }
|
### Question:
PedigreeQueryDecorator { public ImmutableSet<String> getParentNames() { ImmutableSet.Builder<String> parentNames = new ImmutableSet.Builder<String>(); for (Person member : pedigree.getMembers()) { if (member.getFather() != null) parentNames.add(member.getFather().getName()); if (member.getMother() != null) parentNames.add(member.getMother().getName()); } return parentNames.build(); } PedigreeQueryDecorator(Pedigree pedigree); Pedigree getPedigree(); boolean isParentOfAffected(Person person); ImmutableSet<String> getUnaffectedNames(); ImmutableSet<String> getParentNames(); ImmutableSet<String> getAffectedFemaleParentNames(); ImmutableSet<String> getAffectedMaleParentNames(); ImmutableList<Person> getParents(); int getNumberOfParents(); int getNumberOfAffecteds(); int getNumberOfUnaffecteds(); ImmutableMap<Person, ImmutableList<Person>> buildSiblings(); }### Answer:
@Test public void testGetParentNames() { Assert.assertEquals(ImmutableSet.of("father", "mother"), decorator.getParentNames()); }
|
### Question:
PedigreeQueryDecorator { public ImmutableList<Person> getParents() { ImmutableSet<String> parentNames = getParentNames(); ImmutableList.Builder<Person> builder = new ImmutableList.Builder<Person>(); for (Person member : pedigree.getMembers()) if (parentNames.contains(member.getName())) builder.add(member); return builder.build(); } PedigreeQueryDecorator(Pedigree pedigree); Pedigree getPedigree(); boolean isParentOfAffected(Person person); ImmutableSet<String> getUnaffectedNames(); ImmutableSet<String> getParentNames(); ImmutableSet<String> getAffectedFemaleParentNames(); ImmutableSet<String> getAffectedMaleParentNames(); ImmutableList<Person> getParents(); int getNumberOfParents(); int getNumberOfAffecteds(); int getNumberOfUnaffecteds(); ImmutableMap<Person, ImmutableList<Person>> buildSiblings(); }### Answer:
@Test public void testGetParents() { Assert.assertEquals(ImmutableList.of(pedigree.getMembers().get(0), pedigree.getMembers().get(1)), decorator.getParents()); }
|
### Question:
PedigreeQueryDecorator { public int getNumberOfParents() { HashSet<String> parentNames = new HashSet<String>(); for (Person member : pedigree.getMembers()) { if (member.getFather() != null) parentNames.add(member.getFather().getName()); if (member.getMother() != null) parentNames.add(member.getMother().getName()); } return parentNames.size(); } PedigreeQueryDecorator(Pedigree pedigree); Pedigree getPedigree(); boolean isParentOfAffected(Person person); ImmutableSet<String> getUnaffectedNames(); ImmutableSet<String> getParentNames(); ImmutableSet<String> getAffectedFemaleParentNames(); ImmutableSet<String> getAffectedMaleParentNames(); ImmutableList<Person> getParents(); int getNumberOfParents(); int getNumberOfAffecteds(); int getNumberOfUnaffecteds(); ImmutableMap<Person, ImmutableList<Person>> buildSiblings(); }### Answer:
@Test public void testGetNumberOfParents() { Assert.assertEquals(2, decorator.getNumberOfParents()); }
|
### Question:
ProteinPointLocation implements ConvertibleToHGVSString { @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; ProteinPointLocation other = (ProteinPointLocation) obj; if (aa == null) { if (other.aa != null) return false; } else if (!aa.equals(other.aa)) return false; if (downstreamOfTerminal != other.downstreamOfTerminal) return false; if (offset != other.offset) return false; if (pos != other.pos) return false; return true; } ProteinPointLocation(String aa, int pos, int offset, boolean downstreamOfTerminal); static ProteinPointLocation build(String aa, int pos); static ProteinPointLocation buildWithOffset(String aa, int pos, int offset); static ProteinPointLocation buildDownstreamOfTerminal(String aa, int pos); int getPos(); String getAA(); int getOffset(); boolean isDownstreamOfTerminal(); @Override String toHGVSString(); @Override String toHGVSString(AminoAcidCode code); @Override String toString(); @Override int hashCode(); @Override boolean equals(Object obj); }### Answer:
@Test public void testEquals() { Assert.assertTrue(location1.equals(location2)); Assert.assertTrue(location2.equals(location1)); Assert.assertFalse(location1.equals(location3)); Assert.assertFalse(location3.equals(location1)); }
|
### Question:
PedigreeQueryDecorator { public int getNumberOfAffecteds() { int result = 0; for (Person member : pedigree.getMembers()) if (member.getDisease() == Disease.AFFECTED) result += 1; return result; } PedigreeQueryDecorator(Pedigree pedigree); Pedigree getPedigree(); boolean isParentOfAffected(Person person); ImmutableSet<String> getUnaffectedNames(); ImmutableSet<String> getParentNames(); ImmutableSet<String> getAffectedFemaleParentNames(); ImmutableSet<String> getAffectedMaleParentNames(); ImmutableList<Person> getParents(); int getNumberOfParents(); int getNumberOfAffecteds(); int getNumberOfUnaffecteds(); ImmutableMap<Person, ImmutableList<Person>> buildSiblings(); }### Answer:
@Test public void testGetNumberOfAffecteds() { Assert.assertEquals(1, decorator.getNumberOfAffecteds()); }
|
### Question:
PedigreeQueryDecorator { public int getNumberOfUnaffecteds() { int result = 0; for (Person member : pedigree.getMembers()) if (member.getDisease() == Disease.UNAFFECTED) result += 1; return result; } PedigreeQueryDecorator(Pedigree pedigree); Pedigree getPedigree(); boolean isParentOfAffected(Person person); ImmutableSet<String> getUnaffectedNames(); ImmutableSet<String> getParentNames(); ImmutableSet<String> getAffectedFemaleParentNames(); ImmutableSet<String> getAffectedMaleParentNames(); ImmutableList<Person> getParents(); int getNumberOfParents(); int getNumberOfAffecteds(); int getNumberOfUnaffecteds(); ImmutableMap<Person, ImmutableList<Person>> buildSiblings(); }### Answer:
@Test public void testGetNumberOfUnaffecteds() { Assert.assertEquals(1, decorator.getNumberOfUnaffecteds()); }
|
### Question:
Person { public boolean isFounder() { return (father == null && mother == null); } Person(String name, Person father, Person mother, Sex sex, Disease disease, Collection<String> extraFields); Person(String name, Person father, Person mother, Sex sex, Disease disease); Person(PedPerson pedPerson, PedFileContents pedFileContents, HashMap<String, Person> existing); String getName(); Person getFather(); Person getMother(); Sex getSex(); Disease getDisease(); ImmutableList<String> getExtraFields(); boolean isFounder(); boolean isMale(); boolean isFemale(); boolean isAffected(); boolean isUnaffected(); @Override String toString(); @Override int hashCode(); @Override boolean equals(Object obj); }### Answer:
@Test public void testIsFounderTrue() { Person index = new Person("name", null, null, Sex.MALE, Disease.AFFECTED); Assert.assertTrue(index.isFounder()); }
@Test public void testIsFounderFalse() { Person father = new Person("father", null, null, Sex.MALE, Disease.AFFECTED); Person index = new Person("name", father, null, Sex.MALE, Disease.AFFECTED); Assert.assertFalse(index.isFounder()); }
|
### Question:
GenotypeList { public boolean namesEqual(Pedigree pedigree) { return (pedigree.getNames().equals(names)); } GenotypeList(String geneID, List<String> names, boolean isXChromosomal,
ImmutableList<ImmutableList<Genotype>> calls); String getGeneName(); ImmutableList<String> getNames(); boolean isXChromosomal(); ImmutableList<ImmutableList<Genotype>> getCalls(); boolean namesEqual(Pedigree pedigree); @Override String toString(); }### Answer:
@Test public void testIsNamesEqual() { Assert.assertTrue(list.namesEqual(pedigree1)); Assert.assertFalse(list.namesEqual(pedigree2)); }
|
### Question:
PedFileReader { public PedFileContents read() throws IOException, PedParseException { return read(new FileInputStream(file)); } PedFileReader(File file); PedFileContents read(); static PedFileContents read(InputStream stream); }### Answer:
@Test public void testParseWithHeader() throws PedParseException, IOException { PedFileReader reader = new PedFileReader(this.tmpFileWithHeader); PedFileContents pedFileContents = reader.read(); Assert.assertEquals(pedFileContents.getExtraColumnHeaders().size(), 0); ImmutableList.Builder<PedPerson> individuals = new ImmutableList.Builder<PedPerson>(); individuals.add(new PedPerson("fam", "father", "0", "0", Sex.MALE, Disease.UNKNOWN)); individuals.add(new PedPerson("fam", "mother", "0", "0", Sex.FEMALE, Disease.UNKNOWN)); individuals.add(new PedPerson("fam", "son", "father", "mother", Sex.MALE, Disease.UNKNOWN)); individuals.add(new PedPerson("fam", "daughter", "father", "mother", Sex.FEMALE, Disease.UNKNOWN)); Assert.assertEquals(pedFileContents.getIndividuals(), individuals.build()); }
@Test public void testParseWithoutHeader() throws PedParseException, IOException { PedFileReader reader = new PedFileReader(this.tmpFileWithoutHeader); PedFileContents pedFileContents = reader.read(); Assert.assertEquals(pedFileContents.getExtraColumnHeaders().size(), 0); ImmutableList.Builder<PedPerson> individuals = new ImmutableList.Builder<PedPerson>(); individuals.add(new PedPerson("fam", "father", "0", "0", Sex.MALE, Disease.UNKNOWN)); individuals.add(new PedPerson("fam", "mother", "0", "0", Sex.FEMALE, Disease.UNKNOWN)); individuals.add(new PedPerson("fam", "son", "father", "mother", Sex.MALE, Disease.UNKNOWN)); individuals.add(new PedPerson("fam", "daughter", "father", "mother", Sex.FEMALE, Disease.UNKNOWN)); Assert.assertEquals(pedFileContents.getIndividuals(), individuals.build()); }
|
### Question:
Genotype { @Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((alleleNumbers == null) ? 0 : alleleNumbers.hashCode()); return result; } Genotype(Collection<Integer> alleleNumbers); ImmutableList<Integer> getAlleleNumbers(); int getPloidy(); boolean isDiploid(); boolean isMonoploid(); boolean isHet(); boolean isHomRef(); boolean isHomAlt(); boolean isNotObserved(); @Override String toString(); @Override int hashCode(); @Override boolean equals(Object obj); static final int NO_CALL; static final int REF_CALL; }### Answer:
@Test public void testHashCode() { Map<Genotype, String> map = new HashMap<>(); map.put(new Genotype(Arrays.asList(1, 2)), "ONE"); map.put(new Genotype(Arrays.asList(1, 2)), "TWO"); map.put(new Genotype(Arrays.asList(1, 1)), "THREE"); Map<Genotype, String> expected = new HashMap<>(); expected.put(new Genotype(Arrays.asList(1, 2)), "TWO"); expected.put(new Genotype(Arrays.asList(1, 1)), "THREE"); assertEquals(expected, map); }
|
### Question:
Genotype { @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; Genotype other = (Genotype) obj; if (alleleNumbers == null) { if (other.alleleNumbers != null) return false; } else if (!alleleNumbers.equals(other.alleleNumbers)) return false; return true; } Genotype(Collection<Integer> alleleNumbers); ImmutableList<Integer> getAlleleNumbers(); int getPloidy(); boolean isDiploid(); boolean isMonoploid(); boolean isHet(); boolean isHomRef(); boolean isHomAlt(); boolean isNotObserved(); @Override String toString(); @Override int hashCode(); @Override boolean equals(Object obj); static final int NO_CALL; static final int REF_CALL; }### Answer:
@Test public void testEquals() { Genotype one = new Genotype(Arrays.asList(1, 2)); Genotype two = new Genotype(Arrays.asList(1, 2)); Genotype three = new Genotype(Arrays.asList(1, 1)); Genotype four = new Genotype(Collections.singletonList(1)); assertTrue(one.equals(two)); assertFalse(one.equals(three)); assertFalse(one.equals(four)); }
|
### Question:
TranscriptSequenceOntologyDecorator { public boolean overlapsWithTranslationalStartSite(GenomeInterval interval) { return interval.overlapsWith(getStartCodonInterval()); } TranscriptSequenceOntologyDecorator(TranscriptModel transcript); TranscriptModel getTranscript(); GenomeInterval getStartCodonInterval(); GenomeInterval getStopCodonInterval(); GenomeInterval getFivePrimeUTRInterval(); ImmutableList<GenomeInterval> getFivePrimeUTRExonIntervals(); boolean overlapsWithFivePrimeUTRExon(GenomeInterval itv); GenomeInterval getThreePrimeUTRInterval(); ImmutableList<GenomeInterval> getThreePrimeUTRExonIntervals(); boolean overlapsWithThreePrimeUTRExon(GenomeInterval itv); boolean containsExon(GenomeInterval interval); boolean overlapsWithCDSExon(GenomeInterval interval); boolean liesInCDSExon(GenomeInterval interval); boolean liesInCDSExon(GenomePosition pos); boolean overlapsWithCDS(GenomeInterval interval); boolean liesInCDS(GenomePosition pos); boolean overlapsWithIntron(GenomeInterval changeInterval); boolean liesInIntron(GenomePosition pos); boolean overlapsWithCDSIntron(GenomeInterval changeInterval); boolean liesInCDSIntron(GenomePosition pos); boolean overlapsWithTranslationalStartSite(GenomeInterval interval); boolean liesInTranslationalStartSite(GenomePosition pos); boolean overlapsWithTranslationalStopSite(GenomeInterval interval); boolean liesInTranslationalStopSite(GenomePosition pos); boolean overlapsWithSpliceRegion(GenomeInterval interval); boolean liesInSpliceRegion(GenomePosition pos); boolean overlapsWithSpliceDonorSite(GenomeInterval interval); boolean liesInSpliceDonorSite(GenomePosition pos); boolean overlapsWithSpliceAcceptorSite(GenomeInterval interval); boolean liesInSpliceAcceptorSite(GenomePosition pos); GenomeInterval getUpstreamInterval(); boolean overlapsWithUpstreamRegion(GenomeInterval interval); boolean liesInUpstreamRegion(GenomePosition pos); GenomeInterval getDownstreamInterval(); boolean overlapsWithDownstreamRegion(GenomeInterval interval); boolean liesInDownstreamRegion(GenomePosition pos); boolean overlapsWithFivePrimeUTR(GenomeInterval interval); boolean liesInFivePrimeUTR(GenomePosition pos); boolean overlapsWithThreePrimeUTR(GenomeInterval interval); boolean liesInThreePrimeUTR(GenomePosition pos); boolean liesInIntron(GenomeInterval interval); boolean liesInExon(GenomeInterval interval); boolean liesInExon(GenomePosition pos); boolean overlapsWithExon(GenomeInterval interval); static int UPSTREAM_LENGTH; static int DOWNSTREAM_LENGTH; }### Answer:
@Test public void testTranslationalStartSiteOverlapForward() { TranscriptSequenceOntologyDecorator decorator = new TranscriptSequenceOntologyDecorator(infoForward); Assert.assertFalse(decorator.overlapsWithTranslationalStartSite(new GenomeInterval(refDict, Strand.FWD, 1, 6640666, 6640669, PositionType.ZERO_BASED))); for (int i = 1; i <= 5; ++i) Assert.assertTrue(decorator.overlapsWithTranslationalStartSite(new GenomeInterval(refDict, Strand.FWD, 1, 6640666 + i, 6640669 + i, PositionType.ZERO_BASED))); Assert.assertFalse(decorator.overlapsWithTranslationalStartSite(new GenomeInterval(refDict, Strand.FWD, 1, 6640672, 6640675, PositionType.ZERO_BASED))); }
|
### Question:
ProteinPointLocation implements ConvertibleToHGVSString { @Override public String toHGVSString() { return toHGVSString(AminoAcidCode.THREE_LETTER); } ProteinPointLocation(String aa, int pos, int offset, boolean downstreamOfTerminal); static ProteinPointLocation build(String aa, int pos); static ProteinPointLocation buildWithOffset(String aa, int pos, int offset); static ProteinPointLocation buildDownstreamOfTerminal(String aa, int pos); int getPos(); String getAA(); int getOffset(); boolean isDownstreamOfTerminal(); @Override String toHGVSString(); @Override String toHGVSString(AminoAcidCode code); @Override String toString(); @Override int hashCode(); @Override boolean equals(Object obj); }### Answer:
@Test public void testToHGVSString() { Assert.assertEquals("Ala124", location1.toHGVSString()); Assert.assertEquals("A124", location1.toHGVSString(AminoAcidCode.ONE_LETTER)); Assert.assertEquals("Ala124", location1.toHGVSString(AminoAcidCode.THREE_LETTER)); Assert.assertEquals("Ala124", location1.toHGVSString()); Assert.assertEquals("Cys124", location3.toHGVSString()); Assert.assertEquals("Cys124+1", location4.toHGVSString()); Assert.assertEquals("Cys124-1", location5.toHGVSString()); Assert.assertEquals("Cys*124", location6.toHGVSString()); }
|
### Question:
TranscriptSequenceOntologyDecorator { public boolean overlapsWithTranslationalStopSite(GenomeInterval interval) { return interval.overlapsWith(getStopCodonInterval()); } TranscriptSequenceOntologyDecorator(TranscriptModel transcript); TranscriptModel getTranscript(); GenomeInterval getStartCodonInterval(); GenomeInterval getStopCodonInterval(); GenomeInterval getFivePrimeUTRInterval(); ImmutableList<GenomeInterval> getFivePrimeUTRExonIntervals(); boolean overlapsWithFivePrimeUTRExon(GenomeInterval itv); GenomeInterval getThreePrimeUTRInterval(); ImmutableList<GenomeInterval> getThreePrimeUTRExonIntervals(); boolean overlapsWithThreePrimeUTRExon(GenomeInterval itv); boolean containsExon(GenomeInterval interval); boolean overlapsWithCDSExon(GenomeInterval interval); boolean liesInCDSExon(GenomeInterval interval); boolean liesInCDSExon(GenomePosition pos); boolean overlapsWithCDS(GenomeInterval interval); boolean liesInCDS(GenomePosition pos); boolean overlapsWithIntron(GenomeInterval changeInterval); boolean liesInIntron(GenomePosition pos); boolean overlapsWithCDSIntron(GenomeInterval changeInterval); boolean liesInCDSIntron(GenomePosition pos); boolean overlapsWithTranslationalStartSite(GenomeInterval interval); boolean liesInTranslationalStartSite(GenomePosition pos); boolean overlapsWithTranslationalStopSite(GenomeInterval interval); boolean liesInTranslationalStopSite(GenomePosition pos); boolean overlapsWithSpliceRegion(GenomeInterval interval); boolean liesInSpliceRegion(GenomePosition pos); boolean overlapsWithSpliceDonorSite(GenomeInterval interval); boolean liesInSpliceDonorSite(GenomePosition pos); boolean overlapsWithSpliceAcceptorSite(GenomeInterval interval); boolean liesInSpliceAcceptorSite(GenomePosition pos); GenomeInterval getUpstreamInterval(); boolean overlapsWithUpstreamRegion(GenomeInterval interval); boolean liesInUpstreamRegion(GenomePosition pos); GenomeInterval getDownstreamInterval(); boolean overlapsWithDownstreamRegion(GenomeInterval interval); boolean liesInDownstreamRegion(GenomePosition pos); boolean overlapsWithFivePrimeUTR(GenomeInterval interval); boolean liesInFivePrimeUTR(GenomePosition pos); boolean overlapsWithThreePrimeUTR(GenomeInterval interval); boolean liesInThreePrimeUTR(GenomePosition pos); boolean liesInIntron(GenomeInterval interval); boolean liesInExon(GenomeInterval interval); boolean liesInExon(GenomePosition pos); boolean overlapsWithExon(GenomeInterval interval); static int UPSTREAM_LENGTH; static int DOWNSTREAM_LENGTH; }### Answer:
@Test public void testTranslationalStopSiteOverlapForward() { TranscriptSequenceOntologyDecorator decorator = new TranscriptSequenceOntologyDecorator(infoForward); Assert.assertFalse(decorator.overlapsWithTranslationalStopSite(new GenomeInterval(refDict, Strand.FWD, 1, 6649266, 6649269, PositionType.ZERO_BASED))); for (int i = 1; i <= 5; ++i) Assert.assertTrue(decorator.overlapsWithTranslationalStopSite(new GenomeInterval(refDict, Strand.FWD, 1, 6649266 + i, 6649269 + i, PositionType.ZERO_BASED))); Assert.assertFalse(decorator.overlapsWithTranslationalStopSite(new GenomeInterval(refDict, Strand.FWD, 1, 6649272, 6649275, PositionType.ZERO_BASED))); }
|
### Question:
TranscriptSequenceOntologyDecorator { public boolean liesInExon(GenomeInterval interval) { TranscriptProjectionDecorator projector = new TranscriptProjectionDecorator(transcript); final int exonNo = projector.locateExon(interval.getGenomeBeginPos()); if (exonNo == TranscriptProjectionDecorator.INVALID_EXON_ID) return false; return transcript.getExonRegions().get(exonNo).contains(interval); } TranscriptSequenceOntologyDecorator(TranscriptModel transcript); TranscriptModel getTranscript(); GenomeInterval getStartCodonInterval(); GenomeInterval getStopCodonInterval(); GenomeInterval getFivePrimeUTRInterval(); ImmutableList<GenomeInterval> getFivePrimeUTRExonIntervals(); boolean overlapsWithFivePrimeUTRExon(GenomeInterval itv); GenomeInterval getThreePrimeUTRInterval(); ImmutableList<GenomeInterval> getThreePrimeUTRExonIntervals(); boolean overlapsWithThreePrimeUTRExon(GenomeInterval itv); boolean containsExon(GenomeInterval interval); boolean overlapsWithCDSExon(GenomeInterval interval); boolean liesInCDSExon(GenomeInterval interval); boolean liesInCDSExon(GenomePosition pos); boolean overlapsWithCDS(GenomeInterval interval); boolean liesInCDS(GenomePosition pos); boolean overlapsWithIntron(GenomeInterval changeInterval); boolean liesInIntron(GenomePosition pos); boolean overlapsWithCDSIntron(GenomeInterval changeInterval); boolean liesInCDSIntron(GenomePosition pos); boolean overlapsWithTranslationalStartSite(GenomeInterval interval); boolean liesInTranslationalStartSite(GenomePosition pos); boolean overlapsWithTranslationalStopSite(GenomeInterval interval); boolean liesInTranslationalStopSite(GenomePosition pos); boolean overlapsWithSpliceRegion(GenomeInterval interval); boolean liesInSpliceRegion(GenomePosition pos); boolean overlapsWithSpliceDonorSite(GenomeInterval interval); boolean liesInSpliceDonorSite(GenomePosition pos); boolean overlapsWithSpliceAcceptorSite(GenomeInterval interval); boolean liesInSpliceAcceptorSite(GenomePosition pos); GenomeInterval getUpstreamInterval(); boolean overlapsWithUpstreamRegion(GenomeInterval interval); boolean liesInUpstreamRegion(GenomePosition pos); GenomeInterval getDownstreamInterval(); boolean overlapsWithDownstreamRegion(GenomeInterval interval); boolean liesInDownstreamRegion(GenomePosition pos); boolean overlapsWithFivePrimeUTR(GenomeInterval interval); boolean liesInFivePrimeUTR(GenomePosition pos); boolean overlapsWithThreePrimeUTR(GenomeInterval interval); boolean liesInThreePrimeUTR(GenomePosition pos); boolean liesInIntron(GenomeInterval interval); boolean liesInExon(GenomeInterval interval); boolean liesInExon(GenomePosition pos); boolean overlapsWithExon(GenomeInterval interval); static int UPSTREAM_LENGTH; static int DOWNSTREAM_LENGTH; }### Answer:
@Test public void testLiesInExonForwardSuccess() { TranscriptSequenceOntologyDecorator decorator = new TranscriptSequenceOntologyDecorator(infoForward); Assert.assertTrue(decorator.liesInExon(new GenomeInterval(refDict, Strand.FWD, 1, 6640669, 6640672, PositionType.ZERO_BASED))); Assert.assertTrue(decorator.liesInExon(new GenomeInterval(refDict, Strand.FWD, 1, 6646754, 6646757, PositionType.ZERO_BASED))); }
@Test public void testLiesInExonForwardFailure() { TranscriptSequenceOntologyDecorator decorator = new TranscriptSequenceOntologyDecorator(infoForward); Assert.assertFalse(decorator.liesInExon(new GenomeInterval(refDict, Strand.FWD, 1, 6640195, 6640198, PositionType.ZERO_BASED))); }
|
### Question:
TranscriptSequenceOntologyDecorator { public boolean liesInCDSExon(GenomeInterval interval) { return (transcript.getCDSRegion().contains(interval) && liesInExon(interval)); } TranscriptSequenceOntologyDecorator(TranscriptModel transcript); TranscriptModel getTranscript(); GenomeInterval getStartCodonInterval(); GenomeInterval getStopCodonInterval(); GenomeInterval getFivePrimeUTRInterval(); ImmutableList<GenomeInterval> getFivePrimeUTRExonIntervals(); boolean overlapsWithFivePrimeUTRExon(GenomeInterval itv); GenomeInterval getThreePrimeUTRInterval(); ImmutableList<GenomeInterval> getThreePrimeUTRExonIntervals(); boolean overlapsWithThreePrimeUTRExon(GenomeInterval itv); boolean containsExon(GenomeInterval interval); boolean overlapsWithCDSExon(GenomeInterval interval); boolean liesInCDSExon(GenomeInterval interval); boolean liesInCDSExon(GenomePosition pos); boolean overlapsWithCDS(GenomeInterval interval); boolean liesInCDS(GenomePosition pos); boolean overlapsWithIntron(GenomeInterval changeInterval); boolean liesInIntron(GenomePosition pos); boolean overlapsWithCDSIntron(GenomeInterval changeInterval); boolean liesInCDSIntron(GenomePosition pos); boolean overlapsWithTranslationalStartSite(GenomeInterval interval); boolean liesInTranslationalStartSite(GenomePosition pos); boolean overlapsWithTranslationalStopSite(GenomeInterval interval); boolean liesInTranslationalStopSite(GenomePosition pos); boolean overlapsWithSpliceRegion(GenomeInterval interval); boolean liesInSpliceRegion(GenomePosition pos); boolean overlapsWithSpliceDonorSite(GenomeInterval interval); boolean liesInSpliceDonorSite(GenomePosition pos); boolean overlapsWithSpliceAcceptorSite(GenomeInterval interval); boolean liesInSpliceAcceptorSite(GenomePosition pos); GenomeInterval getUpstreamInterval(); boolean overlapsWithUpstreamRegion(GenomeInterval interval); boolean liesInUpstreamRegion(GenomePosition pos); GenomeInterval getDownstreamInterval(); boolean overlapsWithDownstreamRegion(GenomeInterval interval); boolean liesInDownstreamRegion(GenomePosition pos); boolean overlapsWithFivePrimeUTR(GenomeInterval interval); boolean liesInFivePrimeUTR(GenomePosition pos); boolean overlapsWithThreePrimeUTR(GenomeInterval interval); boolean liesInThreePrimeUTR(GenomePosition pos); boolean liesInIntron(GenomeInterval interval); boolean liesInExon(GenomeInterval interval); boolean liesInExon(GenomePosition pos); boolean overlapsWithExon(GenomeInterval interval); static int UPSTREAM_LENGTH; static int DOWNSTREAM_LENGTH; }### Answer:
@Test public void testLiesInCDSExonForwardSuccess() { TranscriptSequenceOntologyDecorator decorator = new TranscriptSequenceOntologyDecorator(infoForward); Assert.assertTrue(decorator.liesInCDSExon(new GenomeInterval(refDict, Strand.FWD, 1, 6640669, 6640672, PositionType.ZERO_BASED))); Assert.assertTrue(decorator.liesInCDSExon(new GenomeInterval(refDict, Strand.FWD, 1, 6646754, 6646757, PositionType.ZERO_BASED))); }
@Test public void testLiesInCDSExonForwardFailure() { TranscriptSequenceOntologyDecorator decorator = new TranscriptSequenceOntologyDecorator(infoForward); Assert.assertFalse(decorator.liesInCDSExon(new GenomeInterval(refDict, Strand.FWD, 1, 6640668, 6640671, PositionType.ZERO_BASED))); }
|
### Question:
TranscriptSequenceOntologyDecorator { public boolean liesInIntron(GenomePosition pos) { for (int i = 0; i + 1 < transcript.getExonRegions().size(); ++i) { GenomeInterval intronRegion = transcript.intronRegion(i); if (intronRegion.contains(pos)) return true; } return false; } TranscriptSequenceOntologyDecorator(TranscriptModel transcript); TranscriptModel getTranscript(); GenomeInterval getStartCodonInterval(); GenomeInterval getStopCodonInterval(); GenomeInterval getFivePrimeUTRInterval(); ImmutableList<GenomeInterval> getFivePrimeUTRExonIntervals(); boolean overlapsWithFivePrimeUTRExon(GenomeInterval itv); GenomeInterval getThreePrimeUTRInterval(); ImmutableList<GenomeInterval> getThreePrimeUTRExonIntervals(); boolean overlapsWithThreePrimeUTRExon(GenomeInterval itv); boolean containsExon(GenomeInterval interval); boolean overlapsWithCDSExon(GenomeInterval interval); boolean liesInCDSExon(GenomeInterval interval); boolean liesInCDSExon(GenomePosition pos); boolean overlapsWithCDS(GenomeInterval interval); boolean liesInCDS(GenomePosition pos); boolean overlapsWithIntron(GenomeInterval changeInterval); boolean liesInIntron(GenomePosition pos); boolean overlapsWithCDSIntron(GenomeInterval changeInterval); boolean liesInCDSIntron(GenomePosition pos); boolean overlapsWithTranslationalStartSite(GenomeInterval interval); boolean liesInTranslationalStartSite(GenomePosition pos); boolean overlapsWithTranslationalStopSite(GenomeInterval interval); boolean liesInTranslationalStopSite(GenomePosition pos); boolean overlapsWithSpliceRegion(GenomeInterval interval); boolean liesInSpliceRegion(GenomePosition pos); boolean overlapsWithSpliceDonorSite(GenomeInterval interval); boolean liesInSpliceDonorSite(GenomePosition pos); boolean overlapsWithSpliceAcceptorSite(GenomeInterval interval); boolean liesInSpliceAcceptorSite(GenomePosition pos); GenomeInterval getUpstreamInterval(); boolean overlapsWithUpstreamRegion(GenomeInterval interval); boolean liesInUpstreamRegion(GenomePosition pos); GenomeInterval getDownstreamInterval(); boolean overlapsWithDownstreamRegion(GenomeInterval interval); boolean liesInDownstreamRegion(GenomePosition pos); boolean overlapsWithFivePrimeUTR(GenomeInterval interval); boolean liesInFivePrimeUTR(GenomePosition pos); boolean overlapsWithThreePrimeUTR(GenomeInterval interval); boolean liesInThreePrimeUTR(GenomePosition pos); boolean liesInIntron(GenomeInterval interval); boolean liesInExon(GenomeInterval interval); boolean liesInExon(GenomePosition pos); boolean overlapsWithExon(GenomeInterval interval); static int UPSTREAM_LENGTH; static int DOWNSTREAM_LENGTH; }### Answer:
@Test public void testLiesInIntron() { TranscriptSequenceOntologyDecorator decorator = new TranscriptSequenceOntologyDecorator(infoForward); Assert.assertFalse(decorator.liesInIntron(new GenomeInterval(refDict, Strand.FWD, 1, 6640195, 6640600, PositionType.ZERO_BASED))); Assert.assertTrue(decorator.liesInIntron(new GenomeInterval(refDict, Strand.FWD, 1, 6640196, 6640600, PositionType.ZERO_BASED))); Assert.assertFalse(decorator.liesInIntron(new GenomeInterval(refDict, Strand.FWD, 1, 6640196, 6640601, PositionType.ZERO_BASED))); }
|
### Question:
ProteinChangeAllele implements ConvertibleToHGVSString, List<ProteinChange> { public static ProteinChangeAllele build(VariantConfiguration varConfig, ProteinChange... changes) { return new ProteinChangeAllele(varConfig, ImmutableList.copyOf(changes)); } ProteinChangeAllele(VariantConfiguration varConfig, Collection<? extends ProteinChange> changes); static ProteinChangeAllele singleChangeAllele(ProteinChange change); static ProteinChangeAllele build(VariantConfiguration varConfig, ProteinChange... changes); VariantConfiguration getVarConfig(); ImmutableList<ProteinChange> getChanges(); @Override String toHGVSString(); @Override String toHGVSString(AminoAcidCode code); @Override String toString(); @Override int hashCode(); @Override boolean equals(Object obj); @Override int size(); @Override boolean isEmpty(); @Override boolean contains(Object o); @Override Iterator<ProteinChange> iterator(); @Override Object[] toArray(); @Override T[] toArray(T[] a); @Deprecated @Override boolean add(ProteinChange e); @Deprecated @Override boolean remove(Object o); @Override boolean containsAll(Collection<?> c); @Deprecated @Override boolean addAll(Collection<? extends ProteinChange> c); @Deprecated @Override boolean addAll(int index, Collection<? extends ProteinChange> c); @Deprecated @Override boolean removeAll(Collection<?> c); @Deprecated @Override boolean retainAll(Collection<?> c); @Deprecated @Override void clear(); @Override ProteinChange get(int index); @Deprecated @Override ProteinChange set(int index, ProteinChange element); @Deprecated @Override void add(int index, ProteinChange element); @Deprecated @Override ProteinChange remove(int index); @Override int indexOf(Object o); @Override int lastIndexOf(Object o); @Override ListIterator<ProteinChange> listIterator(); @Override ListIterator<ProteinChange> listIterator(int index); @Override List<ProteinChange> subList(int fromIndex, int toIndex); }### Answer:
@Test public void testMultiChangeStaticFactory() { Assert.assertEquals(multiChangeAllele, ProteinChangeAllele.build(VariantConfiguration.CHIMERIC, ProteinSubstitution.build(false, "L", 100, "R"), ProteinSubstitution.build(false, "A", 99, "G"))); }
|
### Question:
TranscriptSequenceOntologyDecorator { public boolean overlapsWithUpstreamRegion(GenomeInterval interval) { GenomeInterval upstream = getUpstreamInterval(); return interval.overlapsWith(upstream); } TranscriptSequenceOntologyDecorator(TranscriptModel transcript); TranscriptModel getTranscript(); GenomeInterval getStartCodonInterval(); GenomeInterval getStopCodonInterval(); GenomeInterval getFivePrimeUTRInterval(); ImmutableList<GenomeInterval> getFivePrimeUTRExonIntervals(); boolean overlapsWithFivePrimeUTRExon(GenomeInterval itv); GenomeInterval getThreePrimeUTRInterval(); ImmutableList<GenomeInterval> getThreePrimeUTRExonIntervals(); boolean overlapsWithThreePrimeUTRExon(GenomeInterval itv); boolean containsExon(GenomeInterval interval); boolean overlapsWithCDSExon(GenomeInterval interval); boolean liesInCDSExon(GenomeInterval interval); boolean liesInCDSExon(GenomePosition pos); boolean overlapsWithCDS(GenomeInterval interval); boolean liesInCDS(GenomePosition pos); boolean overlapsWithIntron(GenomeInterval changeInterval); boolean liesInIntron(GenomePosition pos); boolean overlapsWithCDSIntron(GenomeInterval changeInterval); boolean liesInCDSIntron(GenomePosition pos); boolean overlapsWithTranslationalStartSite(GenomeInterval interval); boolean liesInTranslationalStartSite(GenomePosition pos); boolean overlapsWithTranslationalStopSite(GenomeInterval interval); boolean liesInTranslationalStopSite(GenomePosition pos); boolean overlapsWithSpliceRegion(GenomeInterval interval); boolean liesInSpliceRegion(GenomePosition pos); boolean overlapsWithSpliceDonorSite(GenomeInterval interval); boolean liesInSpliceDonorSite(GenomePosition pos); boolean overlapsWithSpliceAcceptorSite(GenomeInterval interval); boolean liesInSpliceAcceptorSite(GenomePosition pos); GenomeInterval getUpstreamInterval(); boolean overlapsWithUpstreamRegion(GenomeInterval interval); boolean liesInUpstreamRegion(GenomePosition pos); GenomeInterval getDownstreamInterval(); boolean overlapsWithDownstreamRegion(GenomeInterval interval); boolean liesInDownstreamRegion(GenomePosition pos); boolean overlapsWithFivePrimeUTR(GenomeInterval interval); boolean liesInFivePrimeUTR(GenomePosition pos); boolean overlapsWithThreePrimeUTR(GenomeInterval interval); boolean liesInThreePrimeUTR(GenomePosition pos); boolean liesInIntron(GenomeInterval interval); boolean liesInExon(GenomeInterval interval); boolean liesInExon(GenomePosition pos); boolean overlapsWithExon(GenomeInterval interval); static int UPSTREAM_LENGTH; static int DOWNSTREAM_LENGTH; }### Answer:
@Test public void testOverlapsWithUpstreamRegion() { TranscriptSequenceOntologyDecorator decorator = new TranscriptSequenceOntologyDecorator(infoForward); Assert.assertFalse(decorator.overlapsWithUpstreamRegion(new GenomeInterval(refDict, Strand.FWD, 1, 6640062, 6640064, PositionType.ZERO_BASED))); Assert.assertTrue(decorator.overlapsWithUpstreamRegion(new GenomeInterval(refDict, Strand.FWD, 1, 6640061, 6640064, PositionType.ZERO_BASED))); Assert.assertFalse(decorator.overlapsWithUpstreamRegion(new GenomeInterval(refDict, Strand.FWD, 1, 6635060, 6635061, PositionType.ZERO_BASED))); }
|
### Question:
TranscriptSequenceOntologyDecorator { public boolean overlapsWithDownstreamRegion(GenomeInterval interval) { GenomeInterval downstream = getDownstreamInterval(); return interval.overlapsWith(downstream); } TranscriptSequenceOntologyDecorator(TranscriptModel transcript); TranscriptModel getTranscript(); GenomeInterval getStartCodonInterval(); GenomeInterval getStopCodonInterval(); GenomeInterval getFivePrimeUTRInterval(); ImmutableList<GenomeInterval> getFivePrimeUTRExonIntervals(); boolean overlapsWithFivePrimeUTRExon(GenomeInterval itv); GenomeInterval getThreePrimeUTRInterval(); ImmutableList<GenomeInterval> getThreePrimeUTRExonIntervals(); boolean overlapsWithThreePrimeUTRExon(GenomeInterval itv); boolean containsExon(GenomeInterval interval); boolean overlapsWithCDSExon(GenomeInterval interval); boolean liesInCDSExon(GenomeInterval interval); boolean liesInCDSExon(GenomePosition pos); boolean overlapsWithCDS(GenomeInterval interval); boolean liesInCDS(GenomePosition pos); boolean overlapsWithIntron(GenomeInterval changeInterval); boolean liesInIntron(GenomePosition pos); boolean overlapsWithCDSIntron(GenomeInterval changeInterval); boolean liesInCDSIntron(GenomePosition pos); boolean overlapsWithTranslationalStartSite(GenomeInterval interval); boolean liesInTranslationalStartSite(GenomePosition pos); boolean overlapsWithTranslationalStopSite(GenomeInterval interval); boolean liesInTranslationalStopSite(GenomePosition pos); boolean overlapsWithSpliceRegion(GenomeInterval interval); boolean liesInSpliceRegion(GenomePosition pos); boolean overlapsWithSpliceDonorSite(GenomeInterval interval); boolean liesInSpliceDonorSite(GenomePosition pos); boolean overlapsWithSpliceAcceptorSite(GenomeInterval interval); boolean liesInSpliceAcceptorSite(GenomePosition pos); GenomeInterval getUpstreamInterval(); boolean overlapsWithUpstreamRegion(GenomeInterval interval); boolean liesInUpstreamRegion(GenomePosition pos); GenomeInterval getDownstreamInterval(); boolean overlapsWithDownstreamRegion(GenomeInterval interval); boolean liesInDownstreamRegion(GenomePosition pos); boolean overlapsWithFivePrimeUTR(GenomeInterval interval); boolean liesInFivePrimeUTR(GenomePosition pos); boolean overlapsWithThreePrimeUTR(GenomeInterval interval); boolean liesInThreePrimeUTR(GenomePosition pos); boolean liesInIntron(GenomeInterval interval); boolean liesInExon(GenomeInterval interval); boolean liesInExon(GenomePosition pos); boolean overlapsWithExon(GenomeInterval interval); static int UPSTREAM_LENGTH; static int DOWNSTREAM_LENGTH; }### Answer:
@Test public void testOverlapsWithDownstreamRegion() { TranscriptSequenceOntologyDecorator decorator = new TranscriptSequenceOntologyDecorator(infoForward); Assert.assertFalse(decorator.overlapsWithDownstreamRegion(new GenomeInterval(refDict, Strand.FWD, 1, 6649339, 6649340, PositionType.ZERO_BASED))); Assert.assertTrue(decorator.overlapsWithDownstreamRegion(new GenomeInterval(refDict, Strand.FWD, 1, 6649340, 6649341, PositionType.ZERO_BASED))); Assert.assertFalse(decorator.overlapsWithDownstreamRegion(new GenomeInterval(refDict, Strand.FWD, 1, 6659339, 6659340, PositionType.ZERO_BASED))); }
|
### Question:
TranscriptSequenceDecorator { public String getCodonAt(TranscriptPosition txPos, CDSPosition cdsPos) throws InvalidCodonException { int frameShift = cdsPos.getPos() % 3; int codonStart = txPos.getPos() - frameShift; int endPos = codonStart + 3; if (transcript.getTrimmedSequence().length() < endPos) throw new InvalidCodonException("Could not access codon " + codonStart + " - " + endPos + ", transcript sequence length is " + transcript.getTrimmedSequence().length()); return transcript.getTrimmedSequence().substring(codonStart, endPos); } TranscriptSequenceDecorator(TranscriptModel transcript); TranscriptModel getTranscript(); static String codonWithUpdatedBase(String transcriptCodon, int frameShift, char targetNC); static String nucleotidesWithInsertion(String transcriptNTs, int frameShift, String insertion); String getCodonAt(TranscriptPosition txPos, CDSPosition cdsPos); String getCodonsStartingFrom(TranscriptPosition txPos, CDSPosition cdsPos, int count); String getCodonsStartingFrom(TranscriptPosition txPos, CDSPosition cdsPos); }### Answer:
@Test public void testGetCodonAt() throws Exception { TranscriptSequenceDecorator decorator = new TranscriptSequenceDecorator(MODEL); Assert.assertEquals(CODONS[CODONS.length - 1], decorator.getCodonAt(tx(START_LAST_CODON), cds(START_LAST_CODON))); Assert.assertEquals(CODONS[0], decorator.getCodonAt(tx(0), cds(0))); }
|
### Question:
TranscriptSequenceDecorator { public String getCodonsStartingFrom(TranscriptPosition txPos, CDSPosition cdsPos, int count) { int frameShift = cdsPos.getPos() % 3; int codonStart = txPos.getPos() - frameShift; int endPos = codonStart + 3 * count; if (endPos > transcript.getTrimmedSequence().length()) endPos = transcript.getTrimmedSequence().length(); return transcript.getTrimmedSequence().substring(codonStart, endPos); } TranscriptSequenceDecorator(TranscriptModel transcript); TranscriptModel getTranscript(); static String codonWithUpdatedBase(String transcriptCodon, int frameShift, char targetNC); static String nucleotidesWithInsertion(String transcriptNTs, int frameShift, String insertion); String getCodonAt(TranscriptPosition txPos, CDSPosition cdsPos); String getCodonsStartingFrom(TranscriptPosition txPos, CDSPosition cdsPos, int count); String getCodonsStartingFrom(TranscriptPosition txPos, CDSPosition cdsPos); }### Answer:
@Test public void testGetCodonsStartingFrom() throws Exception { TranscriptSequenceDecorator decorator = new TranscriptSequenceDecorator(MODEL); Assert.assertEquals(CODONS[0] + CODONS[1], decorator.getCodonsStartingFrom(tx(0), cds(0), 2)); Assert.assertEquals(CODONS[CODONS.length - 2] + CODONS[CODONS.length - 1], decorator.getCodonsStartingFrom(tx(9), cds(9), 2)); }
|
### Question:
ProteinChangeAllele implements ConvertibleToHGVSString, List<ProteinChange> { @Override public String toHGVSString() { return toHGVSString(AminoAcidCode.THREE_LETTER); } ProteinChangeAllele(VariantConfiguration varConfig, Collection<? extends ProteinChange> changes); static ProteinChangeAllele singleChangeAllele(ProteinChange change); static ProteinChangeAllele build(VariantConfiguration varConfig, ProteinChange... changes); VariantConfiguration getVarConfig(); ImmutableList<ProteinChange> getChanges(); @Override String toHGVSString(); @Override String toHGVSString(AminoAcidCode code); @Override String toString(); @Override int hashCode(); @Override boolean equals(Object obj); @Override int size(); @Override boolean isEmpty(); @Override boolean contains(Object o); @Override Iterator<ProteinChange> iterator(); @Override Object[] toArray(); @Override T[] toArray(T[] a); @Deprecated @Override boolean add(ProteinChange e); @Deprecated @Override boolean remove(Object o); @Override boolean containsAll(Collection<?> c); @Deprecated @Override boolean addAll(Collection<? extends ProteinChange> c); @Deprecated @Override boolean addAll(int index, Collection<? extends ProteinChange> c); @Deprecated @Override boolean removeAll(Collection<?> c); @Deprecated @Override boolean retainAll(Collection<?> c); @Deprecated @Override void clear(); @Override ProteinChange get(int index); @Deprecated @Override ProteinChange set(int index, ProteinChange element); @Deprecated @Override void add(int index, ProteinChange element); @Deprecated @Override ProteinChange remove(int index); @Override int indexOf(Object o); @Override int lastIndexOf(Object o); @Override ListIterator<ProteinChange> listIterator(); @Override ListIterator<ProteinChange> listIterator(int index); @Override List<ProteinChange> subList(int fromIndex, int toIndex); }### Answer:
@Test public void testSingletonToHGVSString() { Assert.assertEquals("[Leu101Arg]", singletonAllele.toHGVSString()); Assert.assertEquals("[Leu101Arg]", singletonAllele.toHGVSString(AminoAcidCode.THREE_LETTER)); Assert.assertEquals("[L101R]", singletonAllele.toHGVSString(AminoAcidCode.ONE_LETTER)); }
@Test public void testMultVariantToHGVSString() { Assert.assertEquals("[Leu101Arg Assert.assertEquals("[Leu101Arg Assert.assertEquals("[L101R }
|
### Question:
ProteinSubstitution extends ProteinChange { @Override public String toHGVSString(AminoAcidCode code) { if (code == AminoAcidCode.THREE_LETTER) return wrapIfOnlyPredicted(location.toHGVSString(code) + Translator.getTranslator().toLong(targetAA)); else return wrapIfOnlyPredicted(location.toHGVSString(code) + targetAA); } ProteinSubstitution(boolean onlyPredicted, ProteinPointLocation location, String targetAA); static ProteinSubstitution build(boolean onlyPredicted, String sourceAA, int pos, String targetAA); static ProteinSubstitution buildWithOffset(boolean onlyPredicted, String sourceAA, int pos, int offset,
String targetAA); static ProteinSubstitution buildDownstreamOfTerminal(boolean onlyPredicted, String sourceAA, int pos,
String targetAA); ProteinPointLocation getLocation(); String getTargetAA(); @Override String toHGVSString(AminoAcidCode code); @Override String toString(); @Override int hashCode(); @Override boolean equals(Object obj); @Override ProteinChange withOnlyPredicted(boolean onlyPredicted); }### Answer:
@Test public void testToHGVSString() { Assert.assertEquals("(A124G)", sub1.toHGVSString(AminoAcidCode.ONE_LETTER)); Assert.assertEquals("(Ala124Gly)", sub1.toHGVSString(AminoAcidCode.THREE_LETTER)); Assert.assertEquals("(A124G)", sub1.toHGVSString()); }
|
### Question:
TranscriptProjectionDecorator { public int exonIDInReferenceOrder(int exonID) { if (transcript.getStrand().isForward()) return exonID; else return transcript.getExonRegions().size() - exonID - 1; } TranscriptProjectionDecorator(TranscriptModel transcript); TranscriptModel getTranscript(); String getCDSTranscript(); String getTranscriptStartingAtCDS(); TranscriptPosition genomeToTranscriptPos(GenomePosition pos); CDSPosition genomeToCDSPos(GenomePosition pos); TranscriptPosition cdsToTranscriptPos(CDSPosition pos); GenomePosition cdsToGenomePos(CDSPosition pos); GenomePosition transcriptToGenomePos(TranscriptPosition pos); int exonIDInReferenceOrder(int exonID); int locateIntron(GenomePosition pos); int locateExon(GenomePosition pos); int locateExon(TranscriptPosition pos); CDSPosition projectGenomeToCDSPosition(GenomePosition pos); CDSInterval projectGenomeToCDSInterval(GenomeInterval interval); TranscriptPosition projectGenomeToTXPosition(GenomePosition pos); TranscriptInterval projectGenomeToTXInterval(GenomeInterval interval); static final int INVALID_EXON_ID; static final int INVALID_INTRON_ID; }### Answer:
@Test public void testExonIDInReferenceOrderForward() { TranscriptProjectionDecorator projector = new TranscriptProjectionDecorator(infoForward); for (int i = 0; i < 11; ++i) Assert.assertEquals(i, projector.exonIDInReferenceOrder(i)); }
@Test public void testExonIDInReferenceOrderReverse() { TranscriptProjectionDecorator projector = new TranscriptProjectionDecorator(infoReverse); for (int i = 0; i < 4; ++i) Assert.assertEquals(3 - i, projector.exonIDInReferenceOrder(i)); }
|
### Question:
TranscriptProjectionDecorator { public TranscriptPosition cdsToTranscriptPos(CDSPosition pos) { final GenomePosition cdsBeginPos = transcript.getCDSRegion().getGenomeBeginPos(); int currPos = 0; for (GenomeInterval region : transcript.getExonRegions()) { if (region.getGenomeEndPos().isLeq(cdsBeginPos)) { currPos += region.length(); } else { currPos += cdsBeginPos.differenceTo(region.getGenomeBeginPos()); break; } } return new TranscriptPosition(transcript, currPos + pos.getPos()); } TranscriptProjectionDecorator(TranscriptModel transcript); TranscriptModel getTranscript(); String getCDSTranscript(); String getTranscriptStartingAtCDS(); TranscriptPosition genomeToTranscriptPos(GenomePosition pos); CDSPosition genomeToCDSPos(GenomePosition pos); TranscriptPosition cdsToTranscriptPos(CDSPosition pos); GenomePosition cdsToGenomePos(CDSPosition pos); GenomePosition transcriptToGenomePos(TranscriptPosition pos); int exonIDInReferenceOrder(int exonID); int locateIntron(GenomePosition pos); int locateExon(GenomePosition pos); int locateExon(TranscriptPosition pos); CDSPosition projectGenomeToCDSPosition(GenomePosition pos); CDSInterval projectGenomeToCDSInterval(GenomeInterval interval); TranscriptPosition projectGenomeToTXPosition(GenomePosition pos); TranscriptInterval projectGenomeToTXInterval(GenomeInterval interval); static final int INVALID_EXON_ID; static final int INVALID_INTRON_ID; }### Answer:
@Test public void testCDSPosToTranscriptPosForward() { TranscriptProjectionDecorator projector = new TranscriptProjectionDecorator(infoForward); Assert.assertEquals(new TranscriptPosition(infoForward, 203), projector.cdsToTranscriptPos(new CDSPosition(infoForward, 0))); Assert.assertEquals(new TranscriptPosition(infoForward, 233), projector.cdsToTranscriptPos(new CDSPosition(infoForward, 30))); Assert.assertEquals(new TranscriptPosition(infoForward, 403), projector.cdsToTranscriptPos(new CDSPosition(infoForward, 200))); Assert.assertEquals(new TranscriptPosition(infoForward, 503), projector.cdsToTranscriptPos(new CDSPosition(infoForward, 300))); }
@Test public void testCDSPosToTranscriptPosReverse() { TranscriptProjectionDecorator projector = new TranscriptProjectionDecorator(infoReverse); Assert.assertEquals(new TranscriptPosition(infoReverse, 559), projector.cdsToTranscriptPos(new CDSPosition(infoReverse, 0))); Assert.assertEquals(new TranscriptPosition(infoReverse, 589), projector.cdsToTranscriptPos(new CDSPosition(infoReverse, 30))); Assert.assertEquals(new TranscriptPosition(infoReverse, 759), projector.cdsToTranscriptPos(new CDSPosition(infoReverse, 200))); Assert.assertEquals(new TranscriptPosition(infoReverse, 859), projector.cdsToTranscriptPos(new CDSPosition(infoReverse, 300))); }
|
### Question:
Anchors { public static int gapLength(List<Anchor> anchors) { if (anchors.size() < 2) { throw new RuntimeException("Must have at least two anchors!"); } return anchors.get(anchors.size() - 1).getGapPos(); } static int gapLength(List<Anchor> anchors); static int seqLength(List<Anchor> anchors); static int projectGapToSeqPos(final List<Anchor> anchors, final int gapPos); static int projectSeqToGapPos(final List<Anchor> anchors, final int seqPos); static int countLeadingGaps(List<Anchor> anchors); static int countTrailingGaps(List<Anchor> anchors); }### Answer:
@Test public void testGapLength() { assertEquals(10, Anchors.gapLength(ungapped)); assertEquals(10, Anchors.gapLength(leadingGap)); assertEquals(10, Anchors.gapLength(oneGap)); assertEquals(10, Anchors.gapLength(twoGaps)); assertEquals(10, Anchors.gapLength(trailingGap)); }
|
### Question:
Anchors { public static int seqLength(List<Anchor> anchors) { if (anchors.size() < 2) { throw new RuntimeException("Must have at least two anchors!"); } return anchors.get(anchors.size() - 1).getSeqPos(); } static int gapLength(List<Anchor> anchors); static int seqLength(List<Anchor> anchors); static int projectGapToSeqPos(final List<Anchor> anchors, final int gapPos); static int projectSeqToGapPos(final List<Anchor> anchors, final int seqPos); static int countLeadingGaps(List<Anchor> anchors); static int countTrailingGaps(List<Anchor> anchors); }### Answer:
@Test public void testSeqLength() { assertEquals(10, Anchors.seqLength(ungapped)); assertEquals(8, Anchors.seqLength(leadingGap)); assertEquals(8, Anchors.seqLength(oneGap)); assertEquals(8, Anchors.seqLength(twoGaps)); assertEquals(8, Anchors.seqLength(trailingGap)); }
|
### Question:
SingleAlleleProteinVariant extends ProteinVariant { @Override public String toHGVSString(AminoAcidCode code) { if (hasOnlyOneChange()) return Joiner.on("").join(getSequenceNamePrefix(), ":p.", getChange().toHGVSString(code)); final String sep = allele.getVarConfig().toHGVSSeparator(); ArrayList<String> parts = new ArrayList<>(); parts.add(getSequenceNamePrefix()); parts.add(":p."); if (hasOnlyOneChange()) { parts.add(getChange().toHGVSString(code)); } else { parts.add("["); boolean first = true; for (ProteinChange change : allele) { if (first) first = false; else parts.add(sep); parts.add(change.toHGVSString(code)); } parts.add("]"); } return Joiner.on("").join(parts); } SingleAlleleProteinVariant(String proteinID, VariantConfiguration varConfig,
Collection<? extends ProteinChange> changes); static SingleAlleleProteinVariant makeSingleChangeVariant(String proteinID, ProteinChange change); static SingleAlleleProteinVariant build(String proteinID, VariantConfiguration varConfig,
ProteinChange... changes); boolean hasOnlyOneChange(); ProteinChange getChange(); ProteinChangeAllele getAllele(); @Override String toHGVSString(AminoAcidCode code); @Override String toString(); @Override int hashCode(); @Override boolean equals(Object obj); }### Answer:
@Test public void testToHGVSStringSingleChange() { Assert.assertEquals("PROTEIN:p.A100G", singleChangeVariant.toHGVSString(AminoAcidCode.ONE_LETTER)); Assert.assertEquals("PROTEIN:p.Ala100Gly", singleChangeVariant.toHGVSString(AminoAcidCode.THREE_LETTER)); Assert.assertEquals("PROTEIN:p.Ala100Gly", singleChangeVariant.toHGVSString()); }
@Test public void testToHGVSStringMultiChange() { Assert.assertEquals("PROTEIN:p.[C100T;A301G]", multiChangeVariant.toHGVSString(AminoAcidCode.ONE_LETTER)); Assert.assertEquals("PROTEIN:p.[Cys100Thr;Ala301Gly]", multiChangeVariant.toHGVSString(AminoAcidCode.THREE_LETTER)); Assert.assertEquals("PROTEIN:p.[Cys100Thr;Ala301Gly]", multiChangeVariant.toHGVSString()); }
|
### Question:
Anchors { public static int countLeadingGaps(List<Anchor> anchors) { if (anchors.size() < 2) { throw new RuntimeException("Must have at least two anchors!"); } else if (anchors.size() < 2 || (anchors.get(0).getSeqPos() != anchors.get(1) .getSeqPos())) { return 0; } else { assert anchors.get(0).getSeqPos() == 0; return anchors.get(1).getGapPos(); } } static int gapLength(List<Anchor> anchors); static int seqLength(List<Anchor> anchors); static int projectGapToSeqPos(final List<Anchor> anchors, final int gapPos); static int projectSeqToGapPos(final List<Anchor> anchors, final int seqPos); static int countLeadingGaps(List<Anchor> anchors); static int countTrailingGaps(List<Anchor> anchors); }### Answer:
@Test public void testCountLeadingGaps() { assertEquals(0, Anchors.countLeadingGaps(ungapped)); assertEquals(2, Anchors.countLeadingGaps(leadingGap)); assertEquals(0, Anchors.countLeadingGaps(oneGap)); assertEquals(0, Anchors.countLeadingGaps(twoGaps)); assertEquals(0, Anchors.countLeadingGaps(trailingGap)); }
|
### Question:
Anchors { public static int countTrailingGaps(List<Anchor> anchors) { final int len = anchors.size(); if (len < 2) { throw new RuntimeException("Must have at least two anchors!"); } else if ((anchors.get(len - 1).getSeqPos() != anchors.get(len - 2).getSeqPos())) { return 0; } else { return anchors.get(len - 1).getGapPos() - anchors.get(len - 2).getGapPos(); } } static int gapLength(List<Anchor> anchors); static int seqLength(List<Anchor> anchors); static int projectGapToSeqPos(final List<Anchor> anchors, final int gapPos); static int projectSeqToGapPos(final List<Anchor> anchors, final int seqPos); static int countLeadingGaps(List<Anchor> anchors); static int countTrailingGaps(List<Anchor> anchors); }### Answer:
@Test public void testCountTrailingGaps() { assertEquals(0, Anchors.countTrailingGaps(ungapped)); assertEquals(0, Anchors.countTrailingGaps(leadingGap)); assertEquals(0, Anchors.countTrailingGaps(oneGap)); assertEquals(0, Anchors.countTrailingGaps(twoGaps)); assertEquals(2, Anchors.countTrailingGaps(trailingGap)); }
|
### Question:
Alignment implements Serializable { public int refLeadingGapLength() { return Anchors.countLeadingGaps(refAnchors); } Alignment(List<Anchor> refAnchors, List<Anchor> qryAnchors); static Alignment createUngappedAlignment(int length); ImmutableList<Anchor> getRefAnchors(); ImmutableList<Anchor> getQryAnchors(); int refLeadingGapLength(); int refTrailingGapLength(); int qryLeadingGapLength(); int qryTrailingGapLength(); int projectRefToQry(int refPos); int projectQryToRef(int qryPos); @Override String toString(); @Override boolean equals(Object o); @Override int hashCode(); }### Answer:
@Test public void refLeadingGapLength() { assertEquals(0, ungapped.refLeadingGapLength()); assertEquals(0, overlap.refLeadingGapLength()); assertEquals(0, refIsLonger.refLeadingGapLength()); assertEquals(2, qryIsLonger.refLeadingGapLength()); }
|
### Question:
Alignment implements Serializable { public int refTrailingGapLength() { return Anchors.countTrailingGaps(refAnchors); } Alignment(List<Anchor> refAnchors, List<Anchor> qryAnchors); static Alignment createUngappedAlignment(int length); ImmutableList<Anchor> getRefAnchors(); ImmutableList<Anchor> getQryAnchors(); int refLeadingGapLength(); int refTrailingGapLength(); int qryLeadingGapLength(); int qryTrailingGapLength(); int projectRefToQry(int refPos); int projectQryToRef(int qryPos); @Override String toString(); @Override boolean equals(Object o); @Override int hashCode(); }### Answer:
@Test public void refTrailingGapLength() { assertEquals(0, ungapped.refTrailingGapLength()); assertEquals(2, overlap.refTrailingGapLength()); assertEquals(0, refIsLonger.refTrailingGapLength()); assertEquals(2, qryIsLonger.refTrailingGapLength()); }
|
### Question:
Alignment implements Serializable { public int qryLeadingGapLength() { return Anchors.countLeadingGaps(qryAnchors); } Alignment(List<Anchor> refAnchors, List<Anchor> qryAnchors); static Alignment createUngappedAlignment(int length); ImmutableList<Anchor> getRefAnchors(); ImmutableList<Anchor> getQryAnchors(); int refLeadingGapLength(); int refTrailingGapLength(); int qryLeadingGapLength(); int qryTrailingGapLength(); int projectRefToQry(int refPos); int projectQryToRef(int qryPos); @Override String toString(); @Override boolean equals(Object o); @Override int hashCode(); }### Answer:
@Test public void qryLeadingGapLength() { assertEquals(0, ungapped.qryLeadingGapLength()); assertEquals(2, overlap.qryLeadingGapLength()); assertEquals(2, refIsLonger.qryLeadingGapLength()); assertEquals(0, qryIsLonger.qryLeadingGapLength()); }
|
### Question:
Alignment implements Serializable { public int qryTrailingGapLength() { return Anchors.countTrailingGaps(qryAnchors); } Alignment(List<Anchor> refAnchors, List<Anchor> qryAnchors); static Alignment createUngappedAlignment(int length); ImmutableList<Anchor> getRefAnchors(); ImmutableList<Anchor> getQryAnchors(); int refLeadingGapLength(); int refTrailingGapLength(); int qryLeadingGapLength(); int qryTrailingGapLength(); int projectRefToQry(int refPos); int projectQryToRef(int qryPos); @Override String toString(); @Override boolean equals(Object o); @Override int hashCode(); }### Answer:
@Test public void qryTrailingGapLength() { assertEquals(0, ungapped.qryTrailingGapLength()); assertEquals(0, overlap.qryTrailingGapLength()); assertEquals(2, refIsLonger.qryTrailingGapLength()); assertEquals(0, qryIsLonger.qryTrailingGapLength()); }
|
### Question:
Alignment implements Serializable { public int projectRefToQry(int refPos) { final int aliPos = Anchors.projectSeqToGapPos(refAnchors, refPos); final int qryPos = Anchors.projectGapToSeqPos(qryAnchors, aliPos); return qryPos; } Alignment(List<Anchor> refAnchors, List<Anchor> qryAnchors); static Alignment createUngappedAlignment(int length); ImmutableList<Anchor> getRefAnchors(); ImmutableList<Anchor> getQryAnchors(); int refLeadingGapLength(); int refTrailingGapLength(); int qryLeadingGapLength(); int qryTrailingGapLength(); int projectRefToQry(int refPos); int projectQryToRef(int qryPos); @Override String toString(); @Override boolean equals(Object o); @Override int hashCode(); }### Answer:
@Test public void projectRefToQuery() { for (int i = 0; i < 10; ++i) { assertEquals(0, ungapped.projectRefToQry(0)); } assertEquals(0, overlap.projectRefToQry(0)); assertEquals(0, overlap.projectRefToQry(1)); assertEquals(0, overlap.projectRefToQry(2)); assertEquals(1, overlap.projectRefToQry(3)); assertEquals(2, overlap.projectRefToQry(4)); assertEquals(3, overlap.projectRefToQry(5)); assertEquals(4, overlap.projectRefToQry(6)); assertEquals(7, overlap.projectRefToQry(7)); assertEquals(0, refIsLonger.projectRefToQry(0)); assertEquals(0, refIsLonger.projectRefToQry(1)); assertEquals(0, refIsLonger.projectRefToQry(2)); assertEquals(1, refIsLonger.projectRefToQry(3)); assertEquals(2, refIsLonger.projectRefToQry(4)); assertEquals(3, refIsLonger.projectRefToQry(5)); assertEquals(4, refIsLonger.projectRefToQry(6)); assertEquals(5, refIsLonger.projectRefToQry(7)); assertEquals(6, refIsLonger.projectRefToQry(8)); assertEquals(6, refIsLonger.projectRefToQry(9)); assertEquals(6, refIsLonger.projectRefToQry(10)); assertEquals(2, qryIsLonger.projectRefToQry(0)); assertEquals(3, qryIsLonger.projectRefToQry(1)); assertEquals(4, qryIsLonger.projectRefToQry(2)); assertEquals(5, qryIsLonger.projectRefToQry(3)); assertEquals(6, qryIsLonger.projectRefToQry(4)); assertEquals(7, qryIsLonger.projectRefToQry(5)); assertEquals(10, qryIsLonger.projectRefToQry(6)); }
|
### Question:
Alignment implements Serializable { public int projectQryToRef(int qryPos) { final int aliPos = Anchors.projectSeqToGapPos(qryAnchors, qryPos); final int refPos = Anchors.projectGapToSeqPos(refAnchors, aliPos); return refPos; } Alignment(List<Anchor> refAnchors, List<Anchor> qryAnchors); static Alignment createUngappedAlignment(int length); ImmutableList<Anchor> getRefAnchors(); ImmutableList<Anchor> getQryAnchors(); int refLeadingGapLength(); int refTrailingGapLength(); int qryLeadingGapLength(); int qryTrailingGapLength(); int projectRefToQry(int refPos); int projectQryToRef(int qryPos); @Override String toString(); @Override boolean equals(Object o); @Override int hashCode(); }### Answer:
@Test public void projectQueryToRef() { for (int i = 0; i < 10; ++i) { assertEquals(0, ungapped.projectQryToRef(0)); } assertEquals(2, overlap.projectQryToRef(0)); assertEquals(3, overlap.projectQryToRef(1)); assertEquals(5, overlap.projectQryToRef(2)); assertEquals(5, overlap.projectQryToRef(3)); assertEquals(6, overlap.projectQryToRef(4)); assertEquals(7, overlap.projectQryToRef(5)); assertEquals(7, overlap.projectQryToRef(6)); assertEquals(7, overlap.projectQryToRef(7)); assertEquals(2, refIsLonger.projectQryToRef(0)); assertEquals(3, refIsLonger.projectQryToRef(1)); assertEquals(4, refIsLonger.projectQryToRef(2)); assertEquals(5, refIsLonger.projectQryToRef(3)); assertEquals(6, refIsLonger.projectQryToRef(4)); assertEquals(7, refIsLonger.projectQryToRef(5)); assertEquals(10, refIsLonger.projectQryToRef(6)); assertEquals(0, qryIsLonger.projectQryToRef(0)); assertEquals(0, qryIsLonger.projectQryToRef(1)); assertEquals(0, qryIsLonger.projectQryToRef(2)); assertEquals(1, qryIsLonger.projectQryToRef(3)); assertEquals(2, qryIsLonger.projectQryToRef(4)); assertEquals(3, qryIsLonger.projectQryToRef(5)); assertEquals(4, qryIsLonger.projectQryToRef(6)); assertEquals(5, qryIsLonger.projectQryToRef(7)); assertEquals(6, qryIsLonger.projectQryToRef(8)); assertEquals(6, qryIsLonger.projectQryToRef(9)); assertEquals(6, qryIsLonger.projectQryToRef(10)); }
|
### Question:
GenomeInterval implements Serializable, Comparable<GenomeInterval> { public boolean isLeftOf(GenomePosition pos) { if (chr != pos.getChr()) return false; pos = ensureSameStrand(pos); return (pos.getPos() >= endPos); } GenomeInterval(ReferenceDictionary refDict, Strand strand, int chr, int beginPos, int endPos); GenomeInterval(ReferenceDictionary refDict, Strand strand, int chr, int beginPos, int endPos,
PositionType positionType); GenomeInterval(GenomePosition pos, int length); ReferenceDictionary getRefDict(); Strand getStrand(); int getChr(); int getBeginPos(); int getEndPos(); GenomeInterval withStrand(Strand strand); GenomePosition getGenomeBeginPos(); GenomePosition getGenomeEndPos(); int length(); GenomeInterval intersection(GenomeInterval other); GenomeInterval union(GenomeInterval other); boolean isLeftOf(GenomePosition pos); boolean isRightOf(GenomePosition pos); boolean isLeftOfGap(GenomePosition pos); boolean isRightOfGap(GenomePosition pos); boolean contains(GenomePosition pos); boolean contains(GenomeInterval other); GenomeInterval withMorePadding(int padding); GenomeInterval withMorePadding(int paddingUpstream, int paddingDownstream); boolean overlapsWith(GenomeInterval other); @Override String toString(); @Override int hashCode(); @Override boolean equals(Object obj); @Override int compareTo(GenomeInterval other); }### Answer:
@Test public void testIsLeftOf() { GenomeInterval interval = new GenomeInterval(refDict, Strand.FWD, 1, 1000, 1200, PositionType.ONE_BASED); Assert.assertTrue(interval.isRightOf(new GenomePosition(refDict, Strand.FWD, 1, 999, PositionType.ONE_BASED))); Assert.assertFalse(interval .isRightOf(new GenomePosition(refDict, Strand.FWD, 1, 1000, PositionType.ONE_BASED))); }
|
### Question:
GenomeInterval implements Serializable, Comparable<GenomeInterval> { public boolean isRightOf(GenomePosition pos) { if (chr != pos.getChr()) return false; pos = ensureSameStrand(pos); return (pos.getPos() < beginPos); } GenomeInterval(ReferenceDictionary refDict, Strand strand, int chr, int beginPos, int endPos); GenomeInterval(ReferenceDictionary refDict, Strand strand, int chr, int beginPos, int endPos,
PositionType positionType); GenomeInterval(GenomePosition pos, int length); ReferenceDictionary getRefDict(); Strand getStrand(); int getChr(); int getBeginPos(); int getEndPos(); GenomeInterval withStrand(Strand strand); GenomePosition getGenomeBeginPos(); GenomePosition getGenomeEndPos(); int length(); GenomeInterval intersection(GenomeInterval other); GenomeInterval union(GenomeInterval other); boolean isLeftOf(GenomePosition pos); boolean isRightOf(GenomePosition pos); boolean isLeftOfGap(GenomePosition pos); boolean isRightOfGap(GenomePosition pos); boolean contains(GenomePosition pos); boolean contains(GenomeInterval other); GenomeInterval withMorePadding(int padding); GenomeInterval withMorePadding(int paddingUpstream, int paddingDownstream); boolean overlapsWith(GenomeInterval other); @Override String toString(); @Override int hashCode(); @Override boolean equals(Object obj); @Override int compareTo(GenomeInterval other); }### Answer:
@Test public void testIsRightOf() { GenomeInterval interval = new GenomeInterval(refDict, Strand.FWD, 1, 1000, 1200, PositionType.ONE_BASED); Assert.assertFalse(interval.isLeftOf(new GenomePosition(refDict, Strand.FWD, 1, 1200, PositionType.ONE_BASED))); Assert.assertTrue(interval.isLeftOf(new GenomePosition(refDict, Strand.FWD, 1, 1201, PositionType.ONE_BASED))); }
|
### Question:
GenomeInterval implements Serializable, Comparable<GenomeInterval> { public boolean contains(GenomePosition pos) { if (chr != pos.getChr()) return false; pos = ensureSameStrand(pos); return (pos.getPos() >= beginPos && pos.getPos() < endPos); } GenomeInterval(ReferenceDictionary refDict, Strand strand, int chr, int beginPos, int endPos); GenomeInterval(ReferenceDictionary refDict, Strand strand, int chr, int beginPos, int endPos,
PositionType positionType); GenomeInterval(GenomePosition pos, int length); ReferenceDictionary getRefDict(); Strand getStrand(); int getChr(); int getBeginPos(); int getEndPos(); GenomeInterval withStrand(Strand strand); GenomePosition getGenomeBeginPos(); GenomePosition getGenomeEndPos(); int length(); GenomeInterval intersection(GenomeInterval other); GenomeInterval union(GenomeInterval other); boolean isLeftOf(GenomePosition pos); boolean isRightOf(GenomePosition pos); boolean isLeftOfGap(GenomePosition pos); boolean isRightOfGap(GenomePosition pos); boolean contains(GenomePosition pos); boolean contains(GenomeInterval other); GenomeInterval withMorePadding(int padding); GenomeInterval withMorePadding(int paddingUpstream, int paddingDownstream); boolean overlapsWith(GenomeInterval other); @Override String toString(); @Override int hashCode(); @Override boolean equals(Object obj); @Override int compareTo(GenomeInterval other); }### Answer:
@Test public void testContainsSameChrYes() { GenomeInterval interval = new GenomeInterval(refDict, Strand.FWD, 1, 1000, 1200, PositionType.ONE_BASED); Assert.assertTrue(interval.contains(new GenomePosition(refDict, Strand.FWD, 1, 1000, PositionType.ONE_BASED))); Assert.assertTrue(interval.contains(new GenomePosition(refDict, Strand.FWD, 1, 1200, PositionType.ONE_BASED))); }
@Test public void testContainsSameChrNo() { GenomeInterval interval = new GenomeInterval(refDict, Strand.FWD, 1, 1000, 1200, PositionType.ONE_BASED); Assert.assertFalse(interval.contains(new GenomePosition(refDict, Strand.FWD, 1, 999, PositionType.ONE_BASED))); Assert.assertFalse(interval.contains(new GenomePosition(refDict, Strand.FWD, 1, 1201, PositionType.ONE_BASED))); }
@Test public void testContainsDifferentChr() { GenomeInterval interval = new GenomeInterval(refDict, Strand.FWD, 1, 1000, 1200, PositionType.ONE_BASED); Assert.assertFalse(interval.contains(new GenomePosition(refDict, Strand.FWD, 2, 1100, PositionType.ONE_BASED))); }
|
### Question:
GenomeInterval implements Serializable, Comparable<GenomeInterval> { public GenomeInterval intersection(GenomeInterval other) { if (chr != other.chr) return new GenomeInterval(refDict, strand, chr, beginPos, beginPos, PositionType.ZERO_BASED); other = other.withStrand(strand); int beginPos = Math.max(this.beginPos, other.beginPos); int endPos = Math.min(this.endPos, other.endPos); if (endPos < beginPos) beginPos = endPos; return new GenomeInterval(refDict, strand, chr, beginPos, endPos, PositionType.ZERO_BASED); } GenomeInterval(ReferenceDictionary refDict, Strand strand, int chr, int beginPos, int endPos); GenomeInterval(ReferenceDictionary refDict, Strand strand, int chr, int beginPos, int endPos,
PositionType positionType); GenomeInterval(GenomePosition pos, int length); ReferenceDictionary getRefDict(); Strand getStrand(); int getChr(); int getBeginPos(); int getEndPos(); GenomeInterval withStrand(Strand strand); GenomePosition getGenomeBeginPos(); GenomePosition getGenomeEndPos(); int length(); GenomeInterval intersection(GenomeInterval other); GenomeInterval union(GenomeInterval other); boolean isLeftOf(GenomePosition pos); boolean isRightOf(GenomePosition pos); boolean isLeftOfGap(GenomePosition pos); boolean isRightOfGap(GenomePosition pos); boolean contains(GenomePosition pos); boolean contains(GenomeInterval other); GenomeInterval withMorePadding(int padding); GenomeInterval withMorePadding(int paddingUpstream, int paddingDownstream); boolean overlapsWith(GenomeInterval other); @Override String toString(); @Override int hashCode(); @Override boolean equals(Object obj); @Override int compareTo(GenomeInterval other); }### Answer:
@Test public void testIntersection() { GenomeInterval intervalL = new GenomeInterval(refDict, Strand.FWD, 1, 1000, 1200, PositionType.ONE_BASED); GenomeInterval intervalR = new GenomeInterval(refDict, Strand.FWD, 1, 1100, 1300, PositionType.ONE_BASED); GenomeInterval intervalE = new GenomeInterval(refDict, Strand.FWD, 1, 1100, 1200, PositionType.ONE_BASED); Assert.assertEquals(intervalE, intervalL.intersection(intervalR)); Assert.assertEquals(intervalE, intervalR.intersection(intervalL)); }
|
### Question:
GenomePosition implements Serializable, Comparable<GenomePosition> { public boolean isLt(GenomePosition other) { if (other.strand != strand) other = other.withStrand(strand); return (pos < other.pos); } GenomePosition(ReferenceDictionary refDict, Strand strand, int chr, int pos); GenomePosition(ReferenceDictionary refDict, Strand strand, int chr, int pos, PositionType positionType); GenomePosition(GenomePosition other); GenomePosition(GenomePosition other, Strand strand); ReferenceDictionary getRefDict(); Strand getStrand(); int getChr(); int getPos(); GenomePosition withStrand(Strand strand); boolean isLt(GenomePosition other); boolean isLeq(GenomePosition other); boolean isGt(GenomePosition other); boolean isGeq(GenomePosition other); boolean isEq(GenomePosition other); int differenceTo(GenomePosition pos); int differenceTo(GenomeInterval itv); GenomePosition shifted(int delta); @Override String toString(); @Override int hashCode(); @Override boolean equals(Object obj); int compareTo(GenomePosition other); }### Answer:
@Test public void testLt() { GenomePosition posL = new GenomePosition(refDict, Strand.FWD, 1, 100, PositionType.ONE_BASED); GenomePosition posR = new GenomePosition(refDict, Strand.FWD, 1, 101, PositionType.ONE_BASED); Assert.assertTrue(posL.isLt(posR)); Assert.assertFalse(posL.isLt(posL)); Assert.assertFalse(posR.isLt(posL)); }
|
### Question:
GenomePosition implements Serializable, Comparable<GenomePosition> { public boolean isLeq(GenomePosition other) { if (other.chr != chr) return false; if (other.strand != strand) other = other.withStrand(strand); return (pos <= other.pos); } GenomePosition(ReferenceDictionary refDict, Strand strand, int chr, int pos); GenomePosition(ReferenceDictionary refDict, Strand strand, int chr, int pos, PositionType positionType); GenomePosition(GenomePosition other); GenomePosition(GenomePosition other, Strand strand); ReferenceDictionary getRefDict(); Strand getStrand(); int getChr(); int getPos(); GenomePosition withStrand(Strand strand); boolean isLt(GenomePosition other); boolean isLeq(GenomePosition other); boolean isGt(GenomePosition other); boolean isGeq(GenomePosition other); boolean isEq(GenomePosition other); int differenceTo(GenomePosition pos); int differenceTo(GenomeInterval itv); GenomePosition shifted(int delta); @Override String toString(); @Override int hashCode(); @Override boolean equals(Object obj); int compareTo(GenomePosition other); }### Answer:
@Test public void testLeq() { GenomePosition posL = new GenomePosition(refDict, Strand.FWD, 1, 100, PositionType.ONE_BASED); GenomePosition posR = new GenomePosition(refDict, Strand.FWD, 1, 101, PositionType.ONE_BASED); Assert.assertTrue(posL.isLeq(posR)); Assert.assertTrue(posL.isLeq(posL)); Assert.assertFalse(posR.isLeq(posL)); }
|
### Question:
GenomePosition implements Serializable, Comparable<GenomePosition> { public boolean isGt(GenomePosition other) { if (other.chr != chr) return false; if (other.strand != strand) other = other.withStrand(strand); return (pos > other.pos); } GenomePosition(ReferenceDictionary refDict, Strand strand, int chr, int pos); GenomePosition(ReferenceDictionary refDict, Strand strand, int chr, int pos, PositionType positionType); GenomePosition(GenomePosition other); GenomePosition(GenomePosition other, Strand strand); ReferenceDictionary getRefDict(); Strand getStrand(); int getChr(); int getPos(); GenomePosition withStrand(Strand strand); boolean isLt(GenomePosition other); boolean isLeq(GenomePosition other); boolean isGt(GenomePosition other); boolean isGeq(GenomePosition other); boolean isEq(GenomePosition other); int differenceTo(GenomePosition pos); int differenceTo(GenomeInterval itv); GenomePosition shifted(int delta); @Override String toString(); @Override int hashCode(); @Override boolean equals(Object obj); int compareTo(GenomePosition other); }### Answer:
@Test public void testGt() { GenomePosition posL = new GenomePosition(refDict, Strand.FWD, 1, 100, PositionType.ONE_BASED); GenomePosition posR = new GenomePosition(refDict, Strand.FWD, 1, 101, PositionType.ONE_BASED); Assert.assertFalse(posL.isGt(posR)); Assert.assertFalse(posL.isGt(posL)); Assert.assertTrue(posR.isGt(posL)); }
|
### Question:
GenomePosition implements Serializable, Comparable<GenomePosition> { public boolean isGeq(GenomePosition other) { if (other.chr != chr) return false; if (other.strand != strand) other = other.withStrand(strand); return (pos >= other.pos); } GenomePosition(ReferenceDictionary refDict, Strand strand, int chr, int pos); GenomePosition(ReferenceDictionary refDict, Strand strand, int chr, int pos, PositionType positionType); GenomePosition(GenomePosition other); GenomePosition(GenomePosition other, Strand strand); ReferenceDictionary getRefDict(); Strand getStrand(); int getChr(); int getPos(); GenomePosition withStrand(Strand strand); boolean isLt(GenomePosition other); boolean isLeq(GenomePosition other); boolean isGt(GenomePosition other); boolean isGeq(GenomePosition other); boolean isEq(GenomePosition other); int differenceTo(GenomePosition pos); int differenceTo(GenomeInterval itv); GenomePosition shifted(int delta); @Override String toString(); @Override int hashCode(); @Override boolean equals(Object obj); int compareTo(GenomePosition other); }### Answer:
@Test public void testGeq() { GenomePosition posL = new GenomePosition(refDict, Strand.FWD, 1, 100, PositionType.ONE_BASED); GenomePosition posR = new GenomePosition(refDict, Strand.FWD, 1, 101, PositionType.ONE_BASED); Assert.assertFalse(posL.isGeq(posR)); Assert.assertTrue(posL.isGeq(posL)); Assert.assertTrue(posR.isGeq(posL)); }
|
### Question:
GenomePosition implements Serializable, Comparable<GenomePosition> { public boolean isEq(GenomePosition other) { if (other.chr != chr) return false; if (other.strand != strand) other = other.withStrand(strand); return (pos == other.pos); } GenomePosition(ReferenceDictionary refDict, Strand strand, int chr, int pos); GenomePosition(ReferenceDictionary refDict, Strand strand, int chr, int pos, PositionType positionType); GenomePosition(GenomePosition other); GenomePosition(GenomePosition other, Strand strand); ReferenceDictionary getRefDict(); Strand getStrand(); int getChr(); int getPos(); GenomePosition withStrand(Strand strand); boolean isLt(GenomePosition other); boolean isLeq(GenomePosition other); boolean isGt(GenomePosition other); boolean isGeq(GenomePosition other); boolean isEq(GenomePosition other); int differenceTo(GenomePosition pos); int differenceTo(GenomeInterval itv); GenomePosition shifted(int delta); @Override String toString(); @Override int hashCode(); @Override boolean equals(Object obj); int compareTo(GenomePosition other); }### Answer:
@Test public void testEq() { GenomePosition posL = new GenomePosition(refDict, Strand.FWD, 1, 100, PositionType.ONE_BASED); GenomePosition posR = new GenomePosition(refDict, Strand.FWD, 1, 101, PositionType.ONE_BASED); Assert.assertFalse(posL.isEq(posR)); Assert.assertTrue(posL.isEq(posL)); Assert.assertFalse(posR.isEq(posL)); }
|
### Question:
MultiAlleleProteinVariant extends ProteinVariant { @Override public String toHGVSString(AminoAcidCode code) { ArrayList<String> parts = new ArrayList<>(); parts.add(getSequenceNamePrefix()); parts.add(":p."); boolean first = true; for (ProteinChangeAllele allele : alleles) { if (first) first = false; else parts.add(";"); parts.add(allele.toHGVSString(code)); } return Joiner.on("").join(parts); } MultiAlleleProteinVariant(String proteinID, Collection<ProteinChangeAllele> alleles); static MultiAlleleProteinVariant build(String proteinID, ProteinChangeAllele... alleles); ImmutableList<ProteinChangeAllele> getAlleles(); @Override String toHGVSString(AminoAcidCode code); @Override String toString(); @Override int hashCode(); @Override boolean equals(Object obj); }### Answer:
@Test public void testToHGVSStringSingleChange() { Assert.assertEquals("PROTEIN:p.[A100G;T301R]", singleAlleleVariant.toHGVSString(AminoAcidCode.ONE_LETTER)); Assert.assertEquals("PROTEIN:p.[Ala100Gly;Thr301Arg]", singleAlleleVariant.toHGVSString(AminoAcidCode.THREE_LETTER)); Assert.assertEquals("PROTEIN:p.[Ala100Gly;Thr301Arg]", singleAlleleVariant.toHGVSString()); }
@Test public void testToHGVSStringMultiChange() { Assert.assertEquals("PROTEIN:p.[A100G;T301R];[R34V;L301K]", multiAlleleVariant.toHGVSString(AminoAcidCode.ONE_LETTER)); Assert.assertEquals("PROTEIN:p.[Ala100Gly;Thr301Arg];[Arg34Val;Leu301Lys]", multiAlleleVariant.toHGVSString(AminoAcidCode.THREE_LETTER)); Assert.assertEquals("PROTEIN:p.[Ala100Gly;Thr301Arg];[Arg34Val;Leu301Lys]", multiAlleleVariant.toHGVSString()); }
|
### Question:
GenomePosition implements Serializable, Comparable<GenomePosition> { public int differenceTo(GenomePosition pos) { if (chr != pos.chr) throw new InvalidCoordinateException("Coordinates are on different chromosomes " + this + " vs. " + pos); if (pos.strand != strand) pos = pos.withStrand(strand); return (this.pos - pos.pos); } GenomePosition(ReferenceDictionary refDict, Strand strand, int chr, int pos); GenomePosition(ReferenceDictionary refDict, Strand strand, int chr, int pos, PositionType positionType); GenomePosition(GenomePosition other); GenomePosition(GenomePosition other, Strand strand); ReferenceDictionary getRefDict(); Strand getStrand(); int getChr(); int getPos(); GenomePosition withStrand(Strand strand); boolean isLt(GenomePosition other); boolean isLeq(GenomePosition other); boolean isGt(GenomePosition other); boolean isGeq(GenomePosition other); boolean isEq(GenomePosition other); int differenceTo(GenomePosition pos); int differenceTo(GenomeInterval itv); GenomePosition shifted(int delta); @Override String toString(); @Override int hashCode(); @Override boolean equals(Object obj); int compareTo(GenomePosition other); }### Answer:
@Test public void testDifferenceToPositionForward() { GenomePosition posL = new GenomePosition(refDict, Strand.FWD, 1, 100, PositionType.ONE_BASED); GenomePosition posR = new GenomePosition(refDict, Strand.FWD, 1, 101, PositionType.ONE_BASED); Assert.assertEquals(posL.differenceTo(posR), -1); Assert.assertEquals(posL.differenceTo(posL), 0); Assert.assertEquals(posR.differenceTo(posL), 1); }
@Test public void testDifferenceToPositionReverse() { GenomePosition posL = new GenomePosition(refDict, Strand.REV, 1, 100, PositionType.ONE_BASED); GenomePosition posR = new GenomePosition(refDict, Strand.REV, 1, 101, PositionType.ONE_BASED); Assert.assertEquals(posL.differenceTo(posR), -1); Assert.assertEquals(posL.differenceTo(posL), 0); Assert.assertEquals(posR.differenceTo(posL), 1); }
|
### Question:
NucleotideRange implements ConvertibleToHGVSString { @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; NucleotideRange other = (NucleotideRange) obj; if (firstPos == null) { if (other.firstPos != null) return false; } else if (!firstPos.equals(other.firstPos)) return false; if (lastPos == null) { if (other.lastPos != null) return false; } else if (!lastPos.equals(other.lastPos)) return false; return true; } NucleotideRange(NucleotidePointLocation firstPos, NucleotidePointLocation lastPost); static NucleotideRange build(int firstPos, int firstPosOffset, int lastPos, int lastPosOffset); static NucleotideRange buildWithoutOffset(int firstPos, int lastPos); NucleotidePointLocation getFirstPos(); NucleotidePointLocation getLastPos(); @Override String toHGVSString(); @Override String toHGVSString(AminoAcidCode code); @Override String toString(); @Override int hashCode(); @Override boolean equals(Object obj); }### Answer:
@Test public void testEquals() { Assert.assertEquals(firstLoc, firstLoc2); Assert.assertNotEquals(lastLoc, firstLoc); }
|
### Question:
NucleotideRange implements ConvertibleToHGVSString { @Override public String toHGVSString() { if (firstPos.equals(lastPos)) return firstPos.toHGVSString(); else return Joiner.on("").join(firstPos.toHGVSString(), "_", lastPos.toHGVSString()); } NucleotideRange(NucleotidePointLocation firstPos, NucleotidePointLocation lastPost); static NucleotideRange build(int firstPos, int firstPosOffset, int lastPos, int lastPosOffset); static NucleotideRange buildWithoutOffset(int firstPos, int lastPos); NucleotidePointLocation getFirstPos(); NucleotidePointLocation getLastPos(); @Override String toHGVSString(); @Override String toHGVSString(AminoAcidCode code); @Override String toString(); @Override int hashCode(); @Override boolean equals(Object obj); }### Answer:
@Test public void testToHGVSStringRange() { NucleotideRange range = new NucleotideRange(firstLoc, lastLoc); Assert.assertEquals("124_235-1", range.toHGVSString(AminoAcidCode.ONE_LETTER)); Assert.assertEquals("124_235-1", range.toHGVSString(AminoAcidCode.THREE_LETTER)); }
@Test public void testToHGVSStringSinglePos() { NucleotideRange range = new NucleotideRange(firstLoc, firstLoc2); Assert.assertEquals("124", range.toHGVSString(AminoAcidCode.ONE_LETTER)); Assert.assertEquals("124", range.toHGVSString(AminoAcidCode.THREE_LETTER)); }
|
### Question:
GenomeVariant implements VariantDescription { public GenomeInterval getGenomeInterval() { return new GenomeInterval(pos, ref.length()); } GenomeVariant(GenomePosition pos, String ref, String alt); GenomeVariant(GenomePosition pos, String ref, String alt, Strand strand); static boolean wouldBeSymbolicAllele(String allele); @Override String getChrName(); GenomePosition getGenomePos(); @Override int getPos(); @Override String getRef(); @Override String getAlt(); @Override int getChr(); GenomeInterval getGenomeInterval(); GenomeVariant withStrand(Strand strand); @Override String toString(); GenomeVariantType getType(); boolean isTransition(); boolean isTransversion(); @Override int hashCode(); @Override boolean equals(Object obj); @Override int compareTo(Annotation other); }### Answer:
@Test public void testGetGenomeIntervalForward() { GenomeVariant change = new GenomeVariant(this.genomePosOneBasedForward, "A", "C"); GenomeInterval genomeInterval = change.getGenomeInterval(); GenomeInterval expectedInterval = new GenomeInterval(refDict, Strand.FWD, 1, 123, 123, PositionType.ONE_BASED); Assert.assertEquals(expectedInterval, genomeInterval); Assert.assertEquals(expectedInterval, genomeInterval); }
|
### Question:
Translator { public String translateDNA(String dnaseq) { return translateDNA(dnaseq, this.codon1); } private Translator(); static Translator getTranslator(); String translateDNA(String dnaseq); String translateDNA3(String dnaseq); String toLong(String shortAASeq); String toLong(char c); }### Answer:
@Test public void testTranslateDna_tooShort() throws AnnotationException { Assert.assertEquals("", translator.translateDNA("A")); Assert.assertEquals("", translator.translateDNA("AC")); }
@Test public void testTranslateDna_short() throws AnnotationException { Assert.assertEquals("T", translator.translateDNA("ACT")); }
@Test public void testTranslateDna_longer() throws AnnotationException { Assert.assertEquals("M*S", translator.translateDNA("ATGTAGAGT")); }
@Test public void testTranslateDna_tooLonger() throws AnnotationException { Assert.assertEquals("T", translator.translateDNA("ACTG")); }
|
### Question:
NucleotidePointLocation implements ConvertibleToHGVSString { @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; NucleotidePointLocation other = (NucleotidePointLocation) obj; if (basePos != other.basePos) return false; if (downstreamOfCDS != other.downstreamOfCDS) return false; if (offset != other.offset) return false; return true; } @Deprecated // in favour of full constructor NucleotidePointLocation(int basePos); NucleotidePointLocation(int basePos, int offset, boolean downstreamOfCDS); static NucleotidePointLocation build(int basePos); static NucleotidePointLocation buildWithOffset(int basePos, int offset); static NucleotidePointLocation buildDownstreamOfCDS(int basePos); int getBasePos(); int getOffset(); boolean isDownstreamOfCDS(); @Override String toHGVSString(); @Override String toHGVSString(AminoAcidCode code); @Override String toString(); @Override int hashCode(); @Override boolean equals(Object obj); }### Answer:
@Test public void testEquals() { NucleotidePointLocation location1 = new NucleotidePointLocation(123, -3, false); NucleotidePointLocation location2 = new NucleotidePointLocation(123, -3, false); NucleotidePointLocation location3 = new NucleotidePointLocation(123, 3, false); Assert.assertTrue(location1.equals(location2)); Assert.assertTrue(location2.equals(location1)); Assert.assertFalse(location1.equals(location3)); Assert.assertFalse(location3.equals(location1)); }
|
### Question:
Interval implements java.io.Serializable, Comparable<Interval<T>> { public boolean allLeftOf(int point) { return (maxEnd <= point); } Interval(MutableInterval<T> other); Interval(int begin, int end, T value, int maxEnd); int getBegin(); int getEnd(); T getValue(); int getMaxEnd(); boolean allLeftOf(int point); boolean isLeftOf(int point); boolean isRightOf(int point); boolean contains(int point); boolean overlapsWith(int begin, int end); @Override int hashCode(); @Override boolean equals(Object obj); int compareTo(Interval<T> o); @Override String toString(); }### Answer:
@Test public void testAllLeftOf() { Assert.assertFalse(interval.allLeftOf(10)); Assert.assertFalse(interval.allLeftOf(12)); Assert.assertTrue(interval.allLeftOf(13)); Assert.assertTrue(interval.allLeftOf(14)); }
|
### Question:
Interval implements java.io.Serializable, Comparable<Interval<T>> { public int compareTo(Interval<T> o) { final int result = (begin - o.begin); if (result == 0) return (end - o.end); return result; } Interval(MutableInterval<T> other); Interval(int begin, int end, T value, int maxEnd); int getBegin(); int getEnd(); T getValue(); int getMaxEnd(); boolean allLeftOf(int point); boolean isLeftOf(int point); boolean isRightOf(int point); boolean contains(int point); boolean overlapsWith(int begin, int end); @Override int hashCode(); @Override boolean equals(Object obj); int compareTo(Interval<T> o); @Override String toString(); }### Answer:
@Test public void testCompareTo() { Assert.assertTrue(interval.compareTo(new Interval<String>(0, 10, "y", 10)) > 0); Assert.assertTrue(interval.compareTo(new Interval<String>(1, 9, "y", 10)) > 0); Assert.assertTrue(interval.compareTo(new Interval<String>(1, 10, "y", 10)) == 0); Assert.assertTrue(interval.compareTo(new Interval<String>(1, 11, "y", 10)) < 0); Assert.assertTrue(interval.compareTo(new Interval<String>(2, 10, "y", 10)) < 0); }
|
### Question:
Interval implements java.io.Serializable, Comparable<Interval<T>> { public boolean contains(int point) { return ((begin <= point) && (point < end)); } Interval(MutableInterval<T> other); Interval(int begin, int end, T value, int maxEnd); int getBegin(); int getEnd(); T getValue(); int getMaxEnd(); boolean allLeftOf(int point); boolean isLeftOf(int point); boolean isRightOf(int point); boolean contains(int point); boolean overlapsWith(int begin, int end); @Override int hashCode(); @Override boolean equals(Object obj); int compareTo(Interval<T> o); @Override String toString(); }### Answer:
@Test public void testContains() { Assert.assertFalse(interval.contains(0)); Assert.assertTrue(interval.contains(1)); Assert.assertTrue(interval.contains(2)); Assert.assertTrue(interval.contains(9)); Assert.assertFalse(interval.contains(10)); }
|
### Question:
Interval implements java.io.Serializable, Comparable<Interval<T>> { public boolean isLeftOf(int point) { return (end <= point); } Interval(MutableInterval<T> other); Interval(int begin, int end, T value, int maxEnd); int getBegin(); int getEnd(); T getValue(); int getMaxEnd(); boolean allLeftOf(int point); boolean isLeftOf(int point); boolean isRightOf(int point); boolean contains(int point); boolean overlapsWith(int begin, int end); @Override int hashCode(); @Override boolean equals(Object obj); int compareTo(Interval<T> o); @Override String toString(); }### Answer:
@Test public void testIsLeftOf() { Assert.assertFalse(interval.isLeftOf(8)); Assert.assertFalse(interval.isLeftOf(9)); Assert.assertTrue(interval.isLeftOf(10)); Assert.assertTrue(interval.isLeftOf(11)); }
|
### Question:
Interval implements java.io.Serializable, Comparable<Interval<T>> { public boolean isRightOf(int point) { return (point < begin); } Interval(MutableInterval<T> other); Interval(int begin, int end, T value, int maxEnd); int getBegin(); int getEnd(); T getValue(); int getMaxEnd(); boolean allLeftOf(int point); boolean isLeftOf(int point); boolean isRightOf(int point); boolean contains(int point); boolean overlapsWith(int begin, int end); @Override int hashCode(); @Override boolean equals(Object obj); int compareTo(Interval<T> o); @Override String toString(); }### Answer:
@Test public void testIsRightOf() { Assert.assertTrue(interval.isRightOf(-1)); Assert.assertTrue(interval.isRightOf(0)); Assert.assertFalse(interval.isRightOf(1)); Assert.assertFalse(interval.isRightOf(2)); }
|
### Question:
Interval implements java.io.Serializable, Comparable<Interval<T>> { public boolean overlapsWith(int begin, int end) { return ((begin < this.end) && (this.begin < end)); } Interval(MutableInterval<T> other); Interval(int begin, int end, T value, int maxEnd); int getBegin(); int getEnd(); T getValue(); int getMaxEnd(); boolean allLeftOf(int point); boolean isLeftOf(int point); boolean isRightOf(int point); boolean contains(int point); boolean overlapsWith(int begin, int end); @Override int hashCode(); @Override boolean equals(Object obj); int compareTo(Interval<T> o); @Override String toString(); }### Answer:
@Test public void overlapsWith() { Assert.assertTrue(interval.overlapsWith(0, 2)); Assert.assertTrue(interval.overlapsWith(0, 3)); Assert.assertTrue(interval.overlapsWith(0, 20)); Assert.assertTrue(interval.overlapsWith(9, 10)); Assert.assertFalse(interval.overlapsWith(0, 1)); Assert.assertFalse(interval.overlapsWith(10, 11)); }
|
### Question:
FASTAParser { public FASTARecord next() throws IOException { if (lastLine == null) return null; assert lastLine.startsWith(">"); while (true) { if (lastLine != null && !lastLine.isEmpty()) recordBuffer.add(lastLine); lastLine = reader.readLine(); if (lastLine == null || lastLine.startsWith(">")) break; } return buildRecord(); } FASTAParser(File file); FASTAParser(InputStream stream); FASTARecord next(); }### Answer:
@Test public void test() throws IOException { FASTAParser parser = new FASTAParser(stream); FASTARecord first = parser.next(); Assert.assertEquals("1", first.getID()); Assert.assertEquals("comment 1", first.getComment()); Assert.assertEquals("ACGTAACTACGT", first.getSequence()); FASTARecord second = parser.next(); Assert.assertEquals("2", second.getID()); Assert.assertEquals("comment 2", second.getComment()); Assert.assertEquals("AAAA", second.getSequence()); FASTARecord third = parser.next(); Assert.assertNull(third); }
|
### Question:
RefSeqParser implements TranscriptParser { private boolean onlyCurated() { return checkFlagInSection(iniSection.fetch("onlyCurated")); } RefSeqParser(ReferenceDictionary refDict, String basePath, List<String> geneIdentifiers,
Section iniSection); @Override ImmutableList<TranscriptModel> run(); }### Answer:
@Test public void testOnlyCurated() throws TranscriptParseException { RefSeqParser parser = new RefSeqParser(refDict, dataDirectory.getAbsolutePath(), new ArrayList<>(), curatedIniSection); ImmutableList<TranscriptModel> result = parser.run(); Assert.assertEquals(6, result.size()); SortedSet<String> values = new TreeSet<String>(); for (TranscriptModel tx : result) { values.add(tx.toString()); } SortedSet<String> expected = new TreeSet<String>(); expected.addAll(Lists.newArrayList("NM_000539.3(3:g.129247482_129254187)", "NM_001025596.2(11:g.47487489_47510576)", "NM_001172639.1(11:g.47487489_47545540)", "NM_001172640.1(11:g.47487489_47510576)", "NM_006560.3(11:g.47487489_47574792)", "NM_198700.2(11:g.47487489_47516073)")); Assert.assertEquals(expected, values); }
|
### Question:
NucleotidePointLocation implements ConvertibleToHGVSString { @Override public String toHGVSString() { final int shift = (this.basePos >= 0) ? 1 : 0; final String prefix = downstreamOfCDS ? "*" : ""; if (offset == 0) return prefix + Integer.toString(this.basePos + shift); else if (offset > 0) return prefix + Joiner.on("").join(this.basePos + shift, "+", offset); else return prefix + Joiner.on("").join(this.basePos + shift, "-", -offset); } @Deprecated // in favour of full constructor NucleotidePointLocation(int basePos); NucleotidePointLocation(int basePos, int offset, boolean downstreamOfCDS); static NucleotidePointLocation build(int basePos); static NucleotidePointLocation buildWithOffset(int basePos, int offset); static NucleotidePointLocation buildDownstreamOfCDS(int basePos); int getBasePos(); int getOffset(); boolean isDownstreamOfCDS(); @Override String toHGVSString(); @Override String toHGVSString(AminoAcidCode code); @Override String toString(); @Override int hashCode(); @Override boolean equals(Object obj); }### Answer:
@Test public void testToHGVSString() { NucleotidePointLocation location1 = new NucleotidePointLocation(123, -3, false); NucleotidePointLocation location2 = new NucleotidePointLocation(123, 0, true); Assert.assertEquals("124-3", location1.toHGVSString()); Assert.assertEquals("124-3", location1.toHGVSString(AminoAcidCode.ONE_LETTER)); Assert.assertEquals("124-3", location1.toHGVSString(AminoAcidCode.THREE_LETTER)); Assert.assertEquals("*124", location2.toHGVSString()); }
|
### Question:
ProteinSubstitution extends ProteinChange { public static ProteinSubstitution build(boolean onlyPredicted, String sourceAA, int pos, String targetAA) { return new ProteinSubstitution(onlyPredicted, ProteinPointLocation.build(sourceAA, pos), targetAA); } ProteinSubstitution(boolean onlyPredicted, ProteinPointLocation location, String targetAA); static ProteinSubstitution build(boolean onlyPredicted, String sourceAA, int pos, String targetAA); static ProteinSubstitution buildWithOffset(boolean onlyPredicted, String sourceAA, int pos, int offset,
String targetAA); static ProteinSubstitution buildDownstreamOfTerminal(boolean onlyPredicted, String sourceAA, int pos,
String targetAA); ProteinPointLocation getLocation(); String getTargetAA(); @Override String toHGVSString(AminoAcidCode code); @Override String toString(); @Override int hashCode(); @Override boolean equals(Object obj); @Override ProteinChange withOnlyPredicted(boolean onlyPredicted); }### Answer:
@Test public void testFactoryMethod() { Assert.assertEquals(sub1, ProteinSubstitution.build(true, "A", 123, "G")); }
|
### Question:
GFFParser { public FeatureRecord next() throws IOException { if (lastLine == null) return null; FeatureRecord result = recordParser.parseLine(lastLine); do { lastLine = reader.readLine(); } while (lastLine != null && lastLine.startsWith("#")); return result; } GFFParser(File file); GFFParser(InputStream stream); FeatureRecord next(); GFFVersion getGFFVersion(); }### Answer:
@Test public void test() throws IOException { GFFParser parser = new GFFParser(stream); ArrayList<FeatureRecord> records = new ArrayList<>(); FeatureRecord record; while ((record = parser.next()) != null) records.add(record); Assert.assertEquals(12, records.size()); Assert.assertEquals( "FeatureRecord [seqID=NC_000003.11, source=BestRefSeq, type=gene, begin=129247481, end=129254187, score=., strand=FORWARD, phase=0, attributes={Dbxref=GeneID:6010,HGNC:10012,HPRD:01584,MIM:180380, ID=gene7867, Name=RHO, description=rhodopsin, gbkey=Gene, gene=RHO, gene_synonym=CSNBAD1,OPN2,RP4, part=1%2F1}]", records.get(0).toString()); Assert.assertEquals( "FeatureRecord [seqID=NC_000003.11, source=BestRefSeq, type=CDS, begin=129252450, end=129252561, score=., strand=FORWARD, phase=0, attributes={Dbxref=CCDS:CCDS3063.1,GeneID:6010,Genbank:NP_000530.1,HGNC:10012,HPRD:01584,MIM:180380, ID=cds13732, Name=NP_000530.1, Parent=rna17010, gbkey=CDS, gene=RHO, product=rhodopsin, protein_id=NP_000530.1}]", records.get(11).toString()); }
|
### Question:
NucleotideDeletion extends NucleotideChange { @Override public String toString() { return "NucleotideDeletion [range=" + range + ", seq=" + seq + "]"; } NucleotideDeletion(boolean onlyPredicted, NucleotideRange range, NucleotideSeqDescription seq); static NucleotideDeletion buildWithOffset(boolean onlyPredicted, int firstPos, int firstPosOffset,
int lastPos, int lastPosOffset, NucleotideSeqDescription seq); static NucleotideDeletion buildWithOffsetWithSequence(boolean onlyPredicted, int firstPos,
int firstPosOffset, int lastPos, int lastPosOffset, String nts); static NucleotideDeletion buildWithOffsetWithLength(boolean onlyPredicted, int firstPos, int firstPosOffset,
int lastPos, int lastPosOffset, int seqLen); static NucleotideDeletion buildWithOffsetWithoutSeqDescription(boolean onlyPredicted, int firstPos,
int firstPosOffset, int lastPos, int lastPosOffset); static NucleotideDeletion build(boolean onlyPredicted, int firstPos, int lastPos,
NucleotideSeqDescription seq); static NucleotideDeletion buildWithSequence(boolean onlyPredicted, int firstPos, int lastPos, String nts); static NucleotideDeletion buildWithLength(boolean onlyPredicted, int firstPos, int lastPos, int seqLen); static NucleotideDeletion buildWithoutSeqDescription(boolean onlyPredicted, int firstPos, int lastPos); @Override NucleotideDeletion withOnlyPredicted(boolean flag); NucleotideRange getRange(); NucleotideSeqDescription getSeq(); @Override String toHGVSString(); @Override String toString(); @Override int hashCode(); @Override boolean equals(Object obj); }### Answer:
@Test public void testToString() { NucleotideDeletion del = NucleotideDeletion.buildWithOffsetWithLength(true, 123, 0, 124, 0, 2); System.out.println(del); }
|
### Question:
NucleotideShortSequenceRepeatVariability extends NucleotideChange { @Override public String toHGVSString() { return wrapIfOnlyPredicted(Joiner.on("").join(range.toHGVSString(), "(", minCount, "_", maxCount, ")")); } NucleotideShortSequenceRepeatVariability(boolean onlyPredicted, NucleotideRange range, int minCount,
int maxCount); static NucleotideShortSequenceRepeatVariability build(boolean onlyPredicted, NucleotideRange range,
int minCount, int maxCount); @Override NucleotideShortSequenceRepeatVariability withOnlyPredicted(boolean flag); NucleotideRange getRange(); int getMinCount(); int getMaxCount(); @Override String toHGVSString(); @Override String toString(); @Override int hashCode(); @Override boolean equals(Object obj); }### Answer:
@Test public void testToHGVSString() { Assert.assertEquals("21_24(1_2)", srr.toHGVSString()); Assert.assertEquals("21_24(3_6)", srr2.toHGVSString()); }
|
### Question:
NucleotideSubstitution extends NucleotideChange { public static NucleotideSubstitution buildWithOffset(boolean onlyPredicted, int basePos, int posOffset, String fromNT, String toNT) { return new NucleotideSubstitution(onlyPredicted, NucleotidePointLocation.buildWithOffset(basePos, posOffset), fromNT, toNT); } NucleotideSubstitution(boolean onlyPredicted, NucleotidePointLocation position, String fromNT, String toNT); static NucleotideSubstitution buildWithOffset(boolean onlyPredicted, int basePos, int posOffset,
String fromNT, String toNT); static NucleotideSubstitution build(boolean onlyPredicted, int basePos, String fromNT, String toNT); @Override NucleotideSubstitution withOnlyPredicted(boolean flag); NucleotidePointLocation getPosition(); String getFromNT(); String getToNT(); @Override String toHGVSString(); @Override String toString(); @Override int hashCode(); @Override boolean equals(Object obj); }### Answer:
@Test public void testBuildWithOffset() { Assert.assertEquals(subWithOffset, NucleotideSubstitution.buildWithOffset(true, 10, 1, "A", "T")); }
@Test public void testBuildWithoutOffset() { Assert.assertEquals(subWithoutOffset, NucleotideSubstitution.buildWithOffset(true, 10, 0, "A", "T")); }
|
### Question:
NucleotideSubstitution extends NucleotideChange { @Override public String toHGVSString() { return wrapIfOnlyPredicted(Joiner.on("").join(position.toHGVSString(), fromNT, ">", toNT)); } NucleotideSubstitution(boolean onlyPredicted, NucleotidePointLocation position, String fromNT, String toNT); static NucleotideSubstitution buildWithOffset(boolean onlyPredicted, int basePos, int posOffset,
String fromNT, String toNT); static NucleotideSubstitution build(boolean onlyPredicted, int basePos, String fromNT, String toNT); @Override NucleotideSubstitution withOnlyPredicted(boolean flag); NucleotidePointLocation getPosition(); String getFromNT(); String getToNT(); @Override String toHGVSString(); @Override String toString(); @Override int hashCode(); @Override boolean equals(Object obj); }### Answer:
@Test public void testToStringWithOffset() { Assert.assertEquals("(11+1A>T)", subWithOffset.toHGVSString()); }
@Test public void testToStringWithoutOffset() { Assert.assertEquals("(11A>T)", subWithoutOffset.toHGVSString()); }
|
### Question:
MultiAlleleNucleotideVariant extends NucleotideVariant { @Override public String toHGVSString() { ArrayList<String> parts = new ArrayList<>(); parts.add(getRefIDWithVersion()); parts.add(":"); parts.add(seqType.getPrefix()); boolean first = true; for (NucleotideChangeAllele allele : alleles) { if (first) first = false; else parts.add(";"); parts.add(allele.toHGVSString()); } return Joiner.on("").join(parts); } MultiAlleleNucleotideVariant(SequenceType seqType, String refID, String proteinID, int transcriptVersion,
Collection<NucleotideChangeAllele> alleles); MultiAlleleNucleotideVariant(SequenceType seqType, String seqID, Collection<NucleotideChangeAllele> alleles); static MultiAlleleNucleotideVariant build(SequenceType seqType, String seqID,
NucleotideChangeAllele... alleles); ImmutableList<NucleotideChangeAllele> getAlleles(); @Override String toHGVSString(); @Override String toString(); @Override int hashCode(); @Override boolean equals(Object obj); }### Answer:
@Test public void testToHGVSStringSingleChange() { Assert.assertEquals("REF:c.[100A>G;301A>C]", singleAlleleVariant.toHGVSString(AminoAcidCode.ONE_LETTER)); Assert.assertEquals("REF:c.[100A>G;301A>C]", singleAlleleVariant.toHGVSString(AminoAcidCode.THREE_LETTER)); Assert.assertEquals("REF:c.[100A>G;301A>C]", singleAlleleVariant.toHGVSString()); }
@Test public void testToHGVSStringMultiChange() { Assert.assertEquals("REF:c.[100A>G;301A>C];[34T>C;301A>G]", multiAlleleVariant.toHGVSString(AminoAcidCode.ONE_LETTER)); Assert.assertEquals("REF:c.[100A>G;301A>C];[34T>C;301A>G]", multiAlleleVariant.toHGVSString(AminoAcidCode.THREE_LETTER)); Assert.assertEquals("REF:c.[100A>G;301A>C];[34T>C;301A>G]", multiAlleleVariant.toHGVSString()); }
|
### Question:
NucleotideChangeAllele implements ConvertibleToHGVSString, List<NucleotideChange> { public static NucleotideChangeAllele build(VariantConfiguration varConfig, NucleotideChange... changes) { return new NucleotideChangeAllele(varConfig, ImmutableList.copyOf(changes)); } NucleotideChangeAllele(VariantConfiguration varConfig, Collection<? extends NucleotideChange> changes); static NucleotideChangeAllele singleChangeAllele(NucleotideChange change); static NucleotideChangeAllele build(VariantConfiguration varConfig, NucleotideChange... changes); NucleotideChangeAllele withOnlyPredicted(boolean flag); VariantConfiguration getVarConfig(); ImmutableList<NucleotideChange> getChanges(); @Override String toHGVSString(); @Override String toHGVSString(AminoAcidCode code); @Override String toString(); @Override int hashCode(); @Override boolean equals(Object obj); @Override int size(); @Override boolean isEmpty(); @Override boolean contains(Object o); @Override Iterator<NucleotideChange> iterator(); @Override Object[] toArray(); @Override T[] toArray(T[] a); @Deprecated @Override boolean add(NucleotideChange e); @Deprecated @Override boolean remove(Object o); @Override boolean containsAll(Collection<?> c); @Deprecated @Override boolean addAll(Collection<? extends NucleotideChange> c); @Deprecated @Override boolean addAll(int index, Collection<? extends NucleotideChange> c); @Deprecated @Override boolean removeAll(Collection<?> c); @Deprecated @Override boolean retainAll(Collection<?> c); @Deprecated @Override void clear(); @Override NucleotideChange get(int index); @Deprecated @Override NucleotideChange set(int index, NucleotideChange element); @Deprecated @Override void add(int index, NucleotideChange element); @Deprecated @Override NucleotideChange remove(int index); @Override int indexOf(Object o); @Override int lastIndexOf(Object o); @Override ListIterator<NucleotideChange> listIterator(); @Override ListIterator<NucleotideChange> listIterator(int index); @Override List<NucleotideChange> subList(int fromIndex, int toIndex); }### Answer:
@Test public void testMultiChangeStaticFactory() { Assert.assertEquals( multiChangeAllele, NucleotideChangeAllele.build(VariantConfiguration.CHIMERIC, NucleotideSubstitution.build(false, 100, "C", "A"), NucleotideSubstitution.build(false, 99, "C", "A"))); }
|
### Question:
NucleotideChangeAllele implements ConvertibleToHGVSString, List<NucleotideChange> { @Override public String toHGVSString() { return toHGVSString(AminoAcidCode.THREE_LETTER); } NucleotideChangeAllele(VariantConfiguration varConfig, Collection<? extends NucleotideChange> changes); static NucleotideChangeAllele singleChangeAllele(NucleotideChange change); static NucleotideChangeAllele build(VariantConfiguration varConfig, NucleotideChange... changes); NucleotideChangeAllele withOnlyPredicted(boolean flag); VariantConfiguration getVarConfig(); ImmutableList<NucleotideChange> getChanges(); @Override String toHGVSString(); @Override String toHGVSString(AminoAcidCode code); @Override String toString(); @Override int hashCode(); @Override boolean equals(Object obj); @Override int size(); @Override boolean isEmpty(); @Override boolean contains(Object o); @Override Iterator<NucleotideChange> iterator(); @Override Object[] toArray(); @Override T[] toArray(T[] a); @Deprecated @Override boolean add(NucleotideChange e); @Deprecated @Override boolean remove(Object o); @Override boolean containsAll(Collection<?> c); @Deprecated @Override boolean addAll(Collection<? extends NucleotideChange> c); @Deprecated @Override boolean addAll(int index, Collection<? extends NucleotideChange> c); @Deprecated @Override boolean removeAll(Collection<?> c); @Deprecated @Override boolean retainAll(Collection<?> c); @Deprecated @Override void clear(); @Override NucleotideChange get(int index); @Deprecated @Override NucleotideChange set(int index, NucleotideChange element); @Deprecated @Override void add(int index, NucleotideChange element); @Deprecated @Override NucleotideChange remove(int index); @Override int indexOf(Object o); @Override int lastIndexOf(Object o); @Override ListIterator<NucleotideChange> listIterator(); @Override ListIterator<NucleotideChange> listIterator(int index); @Override List<NucleotideChange> subList(int fromIndex, int toIndex); }### Answer:
@Test public void testSingletonToHGVSString() { Assert.assertEquals("[101C>A]", singletonAllele.toHGVSString()); Assert.assertEquals("[101C>A]", singletonAllele.toHGVSString(AminoAcidCode.THREE_LETTER)); Assert.assertEquals("[101C>A]", singletonAllele.toHGVSString(AminoAcidCode.ONE_LETTER)); }
@Test public void testMultVariantToHGVSString() { Assert.assertEquals("[101C>A Assert.assertEquals("[101C>A Assert.assertEquals("[101C>A }
|
### Question:
ProteinFrameshift extends ProteinChange { public static ProteinFrameshift build(boolean onlyPredicted, String wtAA, int position, String targetAA, int shiftLength) { return new ProteinFrameshift(onlyPredicted, ProteinPointLocation.build(wtAA, position), targetAA, shiftLength); } ProteinFrameshift(boolean onlyPredicted, ProteinPointLocation position, String targetAA, int shiftLength); static ProteinFrameshift build(boolean onlyPredicted, String wtAA, int position, String targetAA,
int shiftLength); static ProteinFrameshift build(boolean onlyPredicted, ProteinPointLocation position, String targetAA,
int shiftLength); static ProteinFrameshift buildShort(boolean onlyPredicted, String wtAA, int position); static ProteinFrameshift buildShort(boolean onlyPredicted, ProteinPointLocation position); static ProteinFrameshift buildWithoutTerminal(boolean onlyPredicted, String wtAA, int position,
String targetAA); static ProteinFrameshift buildWithoutTerminal(boolean onlyPredicted, ProteinPointLocation position,
String targetAA); boolean isShort(); boolean isNoTerminalFrameshfit(); ProteinPointLocation getPosition(); String getTargetAA(); int getShiftLength(); @Override String toHGVSString(AminoAcidCode code); @Override String toString(); @Override int hashCode(); @Override boolean equals(Object obj); @Override ProteinChange withOnlyPredicted(boolean onlyPredicted); static final int LEN_NO_TER; static final int LEN_SHORT; }### Answer:
@Test public void testConstructFullFrameshift() { Assert.assertEquals(fullFrameshift, ProteinFrameshift.build(false, position, "T", 23)); }
|
### Question:
SingleAlleleNucleotideVariant extends NucleotideVariant { @Override public String toHGVSString() { if (hasOnlyOneChange()) return Joiner.on("").join(getSequenceNamePrefix(), ":", seqType.getPrefix(), getChange().toHGVSString()); final String sep = allele.getVarConfig().toHGVSSeparator(); ArrayList<String> parts = new ArrayList<>(); parts.add(getSequenceNamePrefix()); parts.add(":"); parts.add(seqType.getPrefix()); if (hasOnlyOneChange()) { parts.add(getChange().toHGVSString()); } else { parts.add("["); boolean first = true; for (NucleotideChange change : allele) { if (first) first = false; else parts.add(sep); parts.add(change.toHGVSString()); } parts.add("]"); } return Joiner.on("").join(parts); } SingleAlleleNucleotideVariant(SequenceType seqType, String seqID, VariantConfiguration varConfig,
Collection<? extends NucleotideChange> changes); SingleAlleleNucleotideVariant(SequenceType seqType, String refID, String proteinID, int transcriptVersion,
NucleotideChangeAllele allele); SingleAlleleNucleotideVariant(SequenceType seqType, String seqID, NucleotideChangeAllele allele); static SingleAlleleNucleotideVariant makeSingleChangeVariant(SequenceType seqType, String seqID,
NucleotideChange change); static SingleAlleleNucleotideVariant build(SequenceType seqType, String seqID,
VariantConfiguration varConfig, NucleotideChange... changes); boolean hasOnlyOneChange(); NucleotideChange getChange(); NucleotideChangeAllele getAllele(); @Override String toHGVSString(); @Override int hashCode(); @Override boolean equals(Object obj); }### Answer:
@Test public void testToHGVSStringSingleChange() { Assert.assertEquals("REF:c.100A>G", singleChangeVariant.toHGVSString(AminoAcidCode.ONE_LETTER)); Assert.assertEquals("REF:c.100A>G", singleChangeVariant.toHGVSString(AminoAcidCode.THREE_LETTER)); Assert.assertEquals("REF:c.100A>G", singleChangeVariant.toHGVSString()); }
@Test public void testToHGVSStringMultiChange() { Assert.assertEquals("REF:c.[100C>T;301A>G]", multiChangeVariant.toHGVSString(AminoAcidCode.ONE_LETTER)); Assert.assertEquals("REF:c.[100C>T;301A>G]", multiChangeVariant.toHGVSString(AminoAcidCode.THREE_LETTER)); Assert.assertEquals("REF:c.[100C>T;301A>G]", multiChangeVariant.toHGVSString()); }
|
### Question:
ClinVarVCFHeaderExtender extends VCFHeaderExtender { @Override public void addHeaders(VCFHeader header, String prefix) { addHeaders(header, prefix, "", ""); final String note = " (requiring no genotype match, only position overlap)"; if (options.isReportOverlapping() && !options.isReportOverlappingAsMatching()) addHeaders(header, prefix, "OVL_", note); } ClinVarVCFHeaderExtender(DBAnnotationOptions options); @Override String getDefaultPrefix(); @Override void addHeaders(VCFHeader header, String prefix); }### Answer:
@Test public void test() { VCFHeader header = new VCFHeader(); Assert.assertEquals(0, header.getFilterLines().size()); Assert.assertEquals(0, header.getInfoHeaderLines().size()); Assert.assertEquals(0, header.getFormatHeaderLines().size()); Assert.assertEquals(0, header.getIDHeaderLines().size()); Assert.assertEquals(0, header.getOtherHeaderLines().size()); DBAnnotationOptions options = DBAnnotationOptions.createDefaults(); options.setReportOverlapping(true); options.setReportOverlappingAsMatching(false); options.setIdentifierPrefix("CLINVAR_"); new ClinVarVCFHeaderExtender(options).addHeaders(header); Assert.assertEquals(0, header.getFilterLines().size()); Assert.assertEquals(6, header.getInfoHeaderLines().size()); Assert.assertEquals(0, header.getFormatHeaderLines().size()); Assert.assertEquals(6, header.getIDHeaderLines().size()); Assert.assertEquals(0, header.getOtherHeaderLines().size()); Assert.assertNotNull(header.getInfoHeaderLine("CLINVAR_BASIC_INFO")); Assert.assertNotNull(header.getInfoHeaderLine("CLINVAR_VAR_INFO")); Assert.assertNotNull(header.getInfoHeaderLine("CLINVAR_DISEASE_INFO")); }
|
### Question:
CosmicVariantContextToRecordConverter implements VariantContextToRecordConverter<CosmicRecord> { @Override public CosmicRecord convert(VariantContext vc) { CosmicRecordBuilder builder = new CosmicRecordBuilder(); builder.setContig(vc.getContig()); builder.setPos(vc.getStart() - 1); builder.setID(vc.getID()); builder.setRef(vc.getReference().getBaseString()); for (Allele all : vc.getAlternateAlleles()) builder.getAlt().add(all.getBaseString()); builder.setSnp(vc.getAttributeAsBoolean("SNP", false)); builder.setCnt(vc.getAttributeAsInt("CNT", 0)); return builder.build(); } @Override CosmicRecord convert(VariantContext vc); }### Answer:
@Test public void test() { CosmicVariantContextToRecordConverter converter = new CosmicVariantContextToRecordConverter(); VariantContext vc = vcfReader.iterator().next(); CosmicRecord record = converter.convert(vc); Assert.assertEquals("CosmicRecord [chrom=1, pos=1230, id=COSM1231, ref=A, alt=[C], cnt=1, snp=false]", record.toString()); }
|
### Question:
CosmicVCFHeaderExtender extends VCFHeaderExtender { @Override public void addHeaders(VCFHeader header, String prefix) { addHeadersInfixes(header, prefix, "", ""); if (options.isReportOverlapping() && !options.isReportOverlappingAsMatching()) addHeadersInfixes(header, prefix, "OVL_", " (requiring no genotype match, only position overlap)"); } CosmicVCFHeaderExtender(DBAnnotationOptions options); @Override String getDefaultPrefix(); @Override void addHeaders(VCFHeader header, String prefix); void addHeadersInfixes(VCFHeader header, String prefix, String infix, String note); }### Answer:
@Test public void test() throws JannovarVarDBException { VCFHeader header = new VCFHeader(); Assert.assertEquals(0, header.getFilterLines().size()); Assert.assertEquals(0, header.getInfoHeaderLines().size()); Assert.assertEquals(0, header.getFormatHeaderLines().size()); Assert.assertEquals(0, header.getIDHeaderLines().size()); Assert.assertEquals(0, header.getOtherHeaderLines().size()); DBAnnotationOptions options = DBAnnotationOptions.createDefaults(); options.setReportOverlapping(true); options.setReportOverlappingAsMatching(false); options.setIdentifierPrefix("COSMIC_"); new CosmicVCFHeaderExtender(options).addHeaders(header); Assert.assertEquals(0, header.getFilterLines().size()); Assert.assertEquals(6, header.getInfoHeaderLines().size()); Assert.assertEquals(0, header.getFormatHeaderLines().size()); Assert.assertEquals(6, header.getIDHeaderLines().size()); Assert.assertEquals(0, header.getOtherHeaderLines().size()); Assert.assertNotNull(header.getInfoHeaderLine("COSMIC_CNT")); Assert.assertNotNull(header.getInfoHeaderLine("COSMIC_SNP")); Assert.assertNotNull(header.getInfoHeaderLine("COSMIC_IDS")); Assert.assertNotNull(header.getInfoHeaderLine("COSMIC_OVL_CNT")); Assert.assertNotNull(header.getInfoHeaderLine("COSMIC_OVL_SNP")); Assert.assertNotNull(header.getInfoHeaderLine("COSMIC_OVL_IDS")); }
|
### Question:
ProteinFrameshift extends ProteinChange { public static ProteinFrameshift buildWithoutTerminal(boolean onlyPredicted, String wtAA, int position, String targetAA) { return new ProteinFrameshift(onlyPredicted, ProteinPointLocation.build(wtAA, position), targetAA, LEN_NO_TER); } ProteinFrameshift(boolean onlyPredicted, ProteinPointLocation position, String targetAA, int shiftLength); static ProteinFrameshift build(boolean onlyPredicted, String wtAA, int position, String targetAA,
int shiftLength); static ProteinFrameshift build(boolean onlyPredicted, ProteinPointLocation position, String targetAA,
int shiftLength); static ProteinFrameshift buildShort(boolean onlyPredicted, String wtAA, int position); static ProteinFrameshift buildShort(boolean onlyPredicted, ProteinPointLocation position); static ProteinFrameshift buildWithoutTerminal(boolean onlyPredicted, String wtAA, int position,
String targetAA); static ProteinFrameshift buildWithoutTerminal(boolean onlyPredicted, ProteinPointLocation position,
String targetAA); boolean isShort(); boolean isNoTerminalFrameshfit(); ProteinPointLocation getPosition(); String getTargetAA(); int getShiftLength(); @Override String toHGVSString(AminoAcidCode code); @Override String toString(); @Override int hashCode(); @Override boolean equals(Object obj); @Override ProteinChange withOnlyPredicted(boolean onlyPredicted); static final int LEN_NO_TER; static final int LEN_SHORT; }### Answer:
@Test public void testConstructNoTerFrameshift() { Assert.assertEquals(noTerFrameshift, ProteinFrameshift.buildWithoutTerminal(false, position, "T")); }
|
### Question:
UK10KVariantContextToRecordConverter implements VariantContextToRecordConverter<UK10KRecord> { @Override public UK10KRecord convert(VariantContext vc) { UK10KRecordBuilder builder = new UK10KRecordBuilder(); builder.setContig(vc.getContig()); builder.setPos(vc.getStart() - 1); builder.setID(vc.getID()); builder.setRef(vc.getReference().getBaseString()); for (Allele all : vc.getAlternateAlleles()) builder.getAlt().add(all.getBaseString()); builder.getFilter().addAll(vc.getFilters()); int an = vc.getAttributeAsInt("AN", 0); builder.setChromCount(an); ArrayList<Integer> counts = Lists.newArrayList(vc.getAttributeAsList("AC").stream() .map(x -> Integer.parseInt((String) x)).collect(Collectors.toList())); builder.setAlleleCounts(counts); builder.setAlleleFrequencies( Lists.newArrayList(counts.stream().map(x -> (1.0 * x) / an).collect(Collectors.toList()))); return builder.build(); } @Override UK10KRecord convert(VariantContext vc); }### Answer:
@Test public void test() { UK10KVariantContextToRecordConverter converter = new UK10KVariantContextToRecordConverter(); VariantContext vc = vcfReader.iterator().next(); UK10KRecord record = converter.convert(vc); Assert.assertEquals( "UK10KRecord [chrom=1, pos=28589, id=., ref=T, alt=[TTGG], filter=[], " + "altAlleleCounts=[7226], chromCount=7562, altAlleleFrequencies=[0.9555673102353874]]", record.toString()); }
|
### Question:
UK10KVCFHeaderExtender extends VCFHeaderExtender { @Override public void addHeaders(VCFHeader header, String prefix) { addHeadersInfixes(header, prefix, "", ""); if (options.isReportOverlapping() && !options.isReportOverlappingAsMatching()) addHeadersInfixes(header, prefix, "OVL_", " (requiring no genotype match, only position overlap)"); } UK10KVCFHeaderExtender(DBAnnotationOptions options); @Override String getDefaultPrefix(); @Override void addHeaders(VCFHeader header, String prefix); void addHeadersInfixes(VCFHeader header, String prefix, String infix, String note); }### Answer:
@Test public void test() throws JannovarVarDBException { VCFHeader header = new VCFHeader(); Assert.assertEquals(0, header.getFilterLines().size()); Assert.assertEquals(0, header.getInfoHeaderLines().size()); Assert.assertEquals(0, header.getFormatHeaderLines().size()); Assert.assertEquals(0, header.getIDHeaderLines().size()); Assert.assertEquals(0, header.getOtherHeaderLines().size()); DBAnnotationOptions options = DBAnnotationOptions.createDefaults(); options.setReportOverlapping(true); options.setReportOverlappingAsMatching(false); options.setIdentifierPrefix("UK10K_"); new UK10KVCFHeaderExtender(options).addHeaders(header); Assert.assertEquals(0, header.getFilterLines().size()); Assert.assertEquals(6, header.getInfoHeaderLines().size()); Assert.assertEquals(0, header.getFormatHeaderLines().size()); Assert.assertEquals(6, header.getIDHeaderLines().size()); Assert.assertEquals(0, header.getOtherHeaderLines().size()); Assert.assertNotNull(header.getInfoHeaderLine("UK10K_AC")); Assert.assertNotNull(header.getInfoHeaderLine("UK10K_AN")); Assert.assertNotNull(header.getInfoHeaderLine("UK10K_AF")); Assert.assertNotNull(header.getInfoHeaderLine("UK10K_OVL_AC")); Assert.assertNotNull(header.getInfoHeaderLine("UK10K_OVL_AN")); Assert.assertNotNull(header.getInfoHeaderLine("UK10K_OVL_AF")); }
|
### Question:
DBSNPVCFHeaderExtender extends VCFHeaderExtender { @Override public void addHeaders(VCFHeader header, String prefix) { addHeadersInfixes(header, prefix, "", ""); if (options.isReportOverlapping() && !options.isReportOverlappingAsMatching()) addHeadersInfixes(header, prefix, "OVL_", " (requiring no genotype match, only position overlap)"); } DBSNPVCFHeaderExtender(DBAnnotationOptions options); @Override String getDefaultPrefix(); @Override void addHeaders(VCFHeader header, String prefix); void addHeadersInfixes(VCFHeader header, String prefix, String infix, String note); }### Answer:
@Test public void test() throws JannovarVarDBException { VCFHeader header = new VCFHeader(); Assert.assertEquals(0, header.getFilterLines().size()); Assert.assertEquals(0, header.getInfoHeaderLines().size()); Assert.assertEquals(0, header.getFormatHeaderLines().size()); Assert.assertEquals(0, header.getIDHeaderLines().size()); Assert.assertEquals(0, header.getOtherHeaderLines().size()); DBAnnotationOptions options = DBAnnotationOptions.createDefaults(); options.setReportOverlapping(true); options.setReportOverlappingAsMatching(false); options.setIdentifierPrefix("DBSNP_"); new DBSNPVCFHeaderExtender(options).addHeaders(header); Assert.assertEquals(0, header.getFilterLines().size()); Assert.assertEquals(12, header.getInfoHeaderLines().size()); Assert.assertEquals(0, header.getFormatHeaderLines().size()); Assert.assertEquals(12, header.getIDHeaderLines().size()); Assert.assertEquals(0, header.getOtherHeaderLines().size()); Assert.assertNotNull(header.getInfoHeaderLine("DBSNP_COMMON")); Assert.assertNotNull(header.getInfoHeaderLine("DBSNP_CAF")); Assert.assertNotNull(header.getInfoHeaderLine("DBSNP_G5")); Assert.assertNotNull(header.getInfoHeaderLine("DBSNP_G5A")); Assert.assertNotNull(header.getInfoHeaderLine("DBSNP_IDS")); Assert.assertNotNull(header.getInfoHeaderLine("DBSNP_SAO")); Assert.assertNotNull(header.getInfoHeaderLine("DBSNP_OVL_COMMON")); Assert.assertNotNull(header.getInfoHeaderLine("DBSNP_OVL_CAF")); Assert.assertNotNull(header.getInfoHeaderLine("DBSNP_OVL_G5")); Assert.assertNotNull(header.getInfoHeaderLine("DBSNP_OVL_G5A")); Assert.assertNotNull(header.getInfoHeaderLine("DBSNP_OVL_IDS")); Assert.assertNotNull(header.getInfoHeaderLine("DBSNP_OVL_SAO")); }
|
### Question:
DBSNPInfoFactory { public DBSNPInfo build(VCFHeader vcfHeader) { String fileDate = vcfHeader.getMetaDataLine("fileDate").getValue(); String source = vcfHeader.getMetaDataLine("source").getValue(); int dbSNPBuildID = Integer.parseInt(vcfHeader.getMetaDataLine("dbSNP_BUILD_ID").getValue()); String reference = vcfHeader.getMetaDataLine("reference").getValue(); String phasing = vcfHeader.getMetaDataLine("phasing").getValue(); return new DBSNPInfo(fileDate, source, dbSNPBuildID, reference, phasing); } DBSNPInfo build(VCFHeader vcfHeader); }### Answer:
@Test public void test() { DBSNPInfoFactory factory = new DBSNPInfoFactory(); DBSNPInfo info = factory.build(vcfReader.getFileHeader()); Assert.assertEquals("20160408", info.getFileDate()); Assert.assertEquals("dbSNP", info.getSource()); Assert.assertEquals(147, info.getDbSNPBuildID()); Assert.assertEquals("GRCh37.p13", info.getReference()); Assert.assertEquals("partial", info.getPhasing()); }
|
### Question:
AlleleMatcher { public Collection<GenotypeMatch> matchGenotypes(VariantContext obsVC, VariantContext dbVC) { List<GenotypeMatch> result = new ArrayList<>(); Collection<VariantDescription> obsVars = ctxToVariants(obsVC); Collection<VariantDescription> dbVars = ctxToVariants(dbVC); int i = 1; for (VariantDescription obsVar : obsVars) { int j = 1; for (VariantDescription dbVar : dbVars) { if (dbVar.equals(obsVar)) result.add(new GenotypeMatch(i, j, obsVC, dbVC, true)); j += 1; } i += 1; } return result; } AlleleMatcher(String pathFasta); Collection<GenotypeMatch> matchGenotypes(VariantContext obsVC, VariantContext dbVC); Collection<GenotypeMatch> positionOverlaps(VariantContext obsVC, VariantContext dbVC); }### Answer:
@Test public void testMatchSingle() throws JannovarVarDBException { AlleleMatcher matcher = new AlleleMatcher(fastaPath); Collection<GenotypeMatch> matches = matcher.matchGenotypes(vcSingle, vcSingle); assertEquals(1, matches.size()); GenotypeMatch first = (GenotypeMatch) matches.toArray()[0]; Assert.assertSame(vcSingle, first.getObsVC()); Assert.assertSame(vcSingle, first.getDBVC()); Assert.assertEquals(1, first.getObservedAllele()); Assert.assertEquals(1, first.getDbAllele()); }
@Test public void testMatchSingleToMultiple() throws JannovarVarDBException { AlleleMatcher matcher = new AlleleMatcher(fastaPath); Collection<GenotypeMatch> matches = matcher.matchGenotypes(vcSingle, vcMultiple); assertEquals(1, matches.size()); GenotypeMatch first = (GenotypeMatch) matches.toArray()[0]; Assert.assertSame(vcSingle, first.getObsVC()); Assert.assertSame(vcMultiple, first.getDBVC()); Assert.assertEquals(1, first.getObservedAllele()); Assert.assertEquals(2, first.getDbAllele()); }
@Test public void testMatchMultipleToSingle() throws JannovarVarDBException { AlleleMatcher matcher = new AlleleMatcher(fastaPath); Collection<GenotypeMatch> matches = matcher.matchGenotypes(vcMultiple, vcSingle); assertEquals(1, matches.size()); GenotypeMatch first = (GenotypeMatch) matches.toArray()[0]; Assert.assertSame(vcMultiple, first.getObsVC()); Assert.assertSame(vcSingle, first.getDBVC()); Assert.assertEquals(2, first.getObservedAllele()); Assert.assertEquals(1, first.getDbAllele()); }
@Test public void testMatchMultipleToMultiple() throws JannovarVarDBException { AlleleMatcher matcher = new AlleleMatcher(fastaPath); Collection<GenotypeMatch> matches = matcher.matchGenotypes(vcMultiple, vcMultiple); assertEquals(2, matches.size()); GenotypeMatch first = (GenotypeMatch) matches.toArray()[0]; Assert.assertSame(vcMultiple, first.getObsVC()); Assert.assertSame(vcMultiple, first.getDBVC()); Assert.assertEquals(1, first.getObservedAllele()); Assert.assertEquals(1, first.getDbAllele()); GenotypeMatch second = (GenotypeMatch) matches.toArray()[1]; Assert.assertSame(vcMultiple, second.getObsVC()); Assert.assertSame(vcMultiple, second.getDBVC()); Assert.assertEquals(2, second.getObservedAllele()); Assert.assertEquals(2, second.getDbAllele()); }
|
### Question:
ProteinFrameshift extends ProteinChange { public static ProteinFrameshift buildShort(boolean onlyPredicted, String wtAA, int position) { return new ProteinFrameshift(onlyPredicted, ProteinPointLocation.build(wtAA, position), null, LEN_SHORT); } ProteinFrameshift(boolean onlyPredicted, ProteinPointLocation position, String targetAA, int shiftLength); static ProteinFrameshift build(boolean onlyPredicted, String wtAA, int position, String targetAA,
int shiftLength); static ProteinFrameshift build(boolean onlyPredicted, ProteinPointLocation position, String targetAA,
int shiftLength); static ProteinFrameshift buildShort(boolean onlyPredicted, String wtAA, int position); static ProteinFrameshift buildShort(boolean onlyPredicted, ProteinPointLocation position); static ProteinFrameshift buildWithoutTerminal(boolean onlyPredicted, String wtAA, int position,
String targetAA); static ProteinFrameshift buildWithoutTerminal(boolean onlyPredicted, ProteinPointLocation position,
String targetAA); boolean isShort(); boolean isNoTerminalFrameshfit(); ProteinPointLocation getPosition(); String getTargetAA(); int getShiftLength(); @Override String toHGVSString(AminoAcidCode code); @Override String toString(); @Override int hashCode(); @Override boolean equals(Object obj); @Override ProteinChange withOnlyPredicted(boolean onlyPredicted); static final int LEN_NO_TER; static final int LEN_SHORT; }### Answer:
@Test public void testConstructShortFrameshift() { Assert.assertEquals(shortFrameshift, ProteinFrameshift.buildShort(false, position)); }
|
### Question:
VariantNormalizer { public VariantDescription normalizeVariant(VariantDescription desc) { final VariantDescription shifted = shiftLeft(desc); return trimBasesLeft(shifted, 0); } VariantNormalizer(String fastaPath); VariantDescription normalizeVariant(VariantDescription desc); VariantDescription normalizeInsertion(VariantDescription desc); }### Answer:
@Test public void testSNV() { VariantDescription descIn = new VariantDescription("braf", 19, "G", "C"); VariantDescription descOut = normalizer.normalizeVariant(descIn); Assert.assertEquals("braf", descOut.getChrom()); Assert.assertEquals(19, descOut.getPos()); Assert.assertEquals("G", descOut.getRef()); Assert.assertEquals("C", descOut.getAlt()); }
@Test public void testOnNormalInsertion() { VariantDescription descIn = new VariantDescription("braf", 19, "G", "GCT"); VariantDescription descOut = normalizer.normalizeVariant(descIn); Assert.assertEquals("braf", descOut.getChrom()); Assert.assertEquals(19, descOut.getPos()); Assert.assertEquals("", descOut.getRef()); Assert.assertEquals("CT", descOut.getAlt()); }
@Test public void testShiftDeletionLeft() { VariantDescription descIn = new VariantDescription("braf", 180, "TGT", "T"); VariantDescription descOut = normalizer.normalizeVariant(descIn); Assert.assertEquals("braf", descOut.getChrom()); Assert.assertEquals(175, descOut.getPos()); Assert.assertEquals("TG", descOut.getRef()); Assert.assertEquals("", descOut.getAlt()); }
@Test public void testShiftInsertionLeft() { VariantDescription descIn = new VariantDescription("braf", 180, "T", "TGT"); VariantDescription descOut = normalizer.normalizeVariant(descIn); Assert.assertEquals("braf", descOut.getChrom()); Assert.assertEquals(175, descOut.getPos()); Assert.assertEquals("", descOut.getRef()); Assert.assertEquals("TG", descOut.getAlt()); }
|
### Question:
GenomeRegionSequenceExtractor { public String load(GenomeInterval region) { region = region.withStrand(Strand.FWD); String contigName = region.getRefDict().getContigIDToName().get(region.getChr()); contigName = mapContigToFasta(contigName); ReferenceSequence seq = indexedFile.getSubsequenceAt(contigName, region.getBeginPos() + 1, region.getEndPos()); return new String(seq.getBases()); } GenomeRegionSequenceExtractor(JannovarData jannovarData, IndexedFastaSequenceFile indexedFile); String load(GenomeInterval region); }### Answer:
@Test public void testLoadGenomeInterval() { GenomeRegionSequenceExtractor extractor = new GenomeRegionSequenceExtractor(jannovarData, this.indexedFile); GenomeInterval region = new GenomeInterval(new GenomePosition(jannovarData.getRefDict(), Strand.FWD, 1, 99), 51); String seq = extractor.load(region); Assert.assertEquals("CTTTAGGCCTGGGAATCAGGAGTGCTATGACAATTTCCTCCAAAGTGGAGA", seq); }
|
### Question:
ProteinFrameshift extends ProteinChange { @Override public String toHGVSString(AminoAcidCode code) { String targetAA = this.targetAA; if (!isShort() && code == AminoAcidCode.THREE_LETTER) targetAA = Translator.getTranslator().toLong(targetAA); if (isShort()) return wrapIfOnlyPredicted(Joiner.on("").join(position.toHGVSString(code), "fs")); else if (shiftLength == LEN_NO_TER) return wrapIfOnlyPredicted(Joiner.on("").join(position.toHGVSString(code), targetAA, "fs*?")); else return wrapIfOnlyPredicted(Joiner.on("").join(position.toHGVSString(code), targetAA, "fs*", shiftLength)); } ProteinFrameshift(boolean onlyPredicted, ProteinPointLocation position, String targetAA, int shiftLength); static ProteinFrameshift build(boolean onlyPredicted, String wtAA, int position, String targetAA,
int shiftLength); static ProteinFrameshift build(boolean onlyPredicted, ProteinPointLocation position, String targetAA,
int shiftLength); static ProteinFrameshift buildShort(boolean onlyPredicted, String wtAA, int position); static ProteinFrameshift buildShort(boolean onlyPredicted, ProteinPointLocation position); static ProteinFrameshift buildWithoutTerminal(boolean onlyPredicted, String wtAA, int position,
String targetAA); static ProteinFrameshift buildWithoutTerminal(boolean onlyPredicted, ProteinPointLocation position,
String targetAA); boolean isShort(); boolean isNoTerminalFrameshfit(); ProteinPointLocation getPosition(); String getTargetAA(); int getShiftLength(); @Override String toHGVSString(AminoAcidCode code); @Override String toString(); @Override int hashCode(); @Override boolean equals(Object obj); @Override ProteinChange withOnlyPredicted(boolean onlyPredicted); static final int LEN_NO_TER; static final int LEN_SHORT; }### Answer:
@Test public void testFullFrameshiftToHGVSString() { Assert.assertEquals("A124Tfs*23", fullFrameshift.toHGVSString()); Assert.assertEquals("Ala124Thrfs*23", fullFrameshift.toHGVSString(AminoAcidCode.THREE_LETTER)); Assert.assertEquals("A124Tfs*23", fullFrameshift.toHGVSString(AminoAcidCode.ONE_LETTER)); }
@Test public void testNoTerFrameshiftToHGVSString() { Assert.assertEquals("A124Tfs*?", noTerFrameshift.toHGVSString()); Assert.assertEquals("Ala124Thrfs*?", noTerFrameshift.toHGVSString(AminoAcidCode.THREE_LETTER)); Assert.assertEquals("A124Tfs*?", noTerFrameshift.toHGVSString(AminoAcidCode.ONE_LETTER)); }
@Test public void testShortFrameshiftToHGVSString() { Assert.assertEquals("A124fs", shortFrameshift.toHGVSString()); Assert.assertEquals("Ala124fs", shortFrameshift.toHGVSString(AminoAcidCode.THREE_LETTER)); Assert.assertEquals("A124fs", shortFrameshift.toHGVSString(AminoAcidCode.ONE_LETTER)); }
|
### Question:
ProteinExtension extends ProteinChange { public static ProteinExtension build(boolean onlyPredicted, String wtAA, int pos, String targetAA, int shift) { return build(onlyPredicted, ProteinPointLocation.build(wtAA, pos), targetAA, shift); } ProteinExtension(boolean onlyPredicted, ProteinPointLocation position, String targetAA, int shift); static ProteinExtension build(boolean onlyPredicted, String wtAA, int pos, String targetAA, int shift); static ProteinExtension build(boolean onlyPredicted, ProteinPointLocation position, String targetAA,
int shift); static ProteinExtension buildWithoutTerminal(boolean onlyPredicted, String wtAA, int pos, String targetAA); static ProteinExtension buildWithoutTerminal(boolean onlyPredicted, ProteinPointLocation position,
String targetAA); ProteinPointLocation getPosition(); String getTargetAA(); int getShift(); boolean isNoTerminalExtension(); @Override String toHGVSString(AminoAcidCode code); @Override String toString(); @Override int hashCode(); @Override boolean equals(Object obj); @Override ProteinChange withOnlyPredicted(boolean onlyPredicted); static final int LEN_NO_TER; }### Answer:
@Test public void testBuildNormalExtension() { Assert.assertEquals(normalExtension, ProteinExtension.build(false, position, "T", 23)); }
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.