use of org.dash.valid.gl.LinkageDisequilibriumGenotypeList in project ImmunogeneticDataTools by nmdp-bioinformatics.
the class HLALinkageDisequilibrium method findLinkedPairs.
private static Set<HaplotypePair> findLinkedPairs(LinkageDisequilibriumGenotypeList glString, EnumSet<Locus> loci, List<DisequilibriumElement> disequilibriumElements, DetectedLinkageFindings findings) {
Set<HaplotypePair> linkedPairs = new HaplotypePairSet(new HaplotypePairComparator());
Set<MultiLocusHaplotype> linkedHaplotypes = new HashSet<MultiLocusHaplotype>();
Set<DetectedDisequilibriumElement> detectedDisequilibriumElements = new HashSet<DetectedDisequilibriumElement>();
MultiLocusHaplotype clonedHaplotype = null;
for (MultiLocusHaplotype possibleHaplotype : glString.getPossibleHaplotypes(loci)) {
List<DisequilibriumElement> shortenedList = new ArrayList<DisequilibriumElement>(disequilibriumElements);
HashMap<Locus, List<String>> hlaElementMap = new HashMap<Locus, List<String>>();
for (Locus locus : possibleHaplotype.getLoci()) {
if (loci.contains(locus)) {
hlaElementMap.put(locus, possibleHaplotype.getAlleles(locus));
}
}
DisequilibriumElement element = new CoreDisequilibriumElement(hlaElementMap, possibleHaplotype);
DetectedDisequilibriumElement detectedElement = null;
while (shortenedList.contains(element)) {
int index = shortenedList.indexOf(element);
clonedHaplotype = new MultiLocusHaplotype(new ConcurrentHashMap<Locus, List<String>>(possibleHaplotype.getAlleleMap()), possibleHaplotype.getHaplotypeInstanceMap(), possibleHaplotype.getDrb345Homozygous());
detectedElement = new DetectedDisequilibriumElement(shortenedList.get(index));
detectedElement.setHaplotype(element.getHaplotype());
clonedHaplotype.setLinkage(detectedElement);
linkedHaplotypes.add(clonedHaplotype);
detectedDisequilibriumElements.add(detectedElement);
shortenedList = shortenedList.subList(index + 1, shortenedList.size());
}
}
findings.addLinkages(detectedDisequilibriumElements);
for (Haplotype haplotype1 : linkedHaplotypes) {
for (Haplotype haplotype2 : linkedHaplotypes) {
int idx = 0;
for (Locus locus : loci) {
if ((!glString.hasHomozygous(locus) && haplotype1.getHaplotypeInstance(locus) == haplotype2.getHaplotypeInstance(locus))) {
// move on to next haplotype2
break;
}
if (idx == loci.size() - 1) {
linkedPairs.add(new HaplotypePair(haplotype1, haplotype2));
}
idx++;
}
}
}
return linkedPairs;
}
use of org.dash.valid.gl.LinkageDisequilibriumGenotypeList in project ImmunogeneticDataTools by nmdp-bioinformatics.
the class LinkageDisequilibriumAnalyzerTest method testLinkageReportingMugs.
@Test
public void testLinkageReportingMugs() throws IOException {
List<LinkageDisequilibriumGenotypeList> glStrings = GLStringUtilities.readGLStringFile("fullyQualifiedExample.txt");
for (LinkageDisequilibriumGenotypeList linkedGLString : glStrings) {
MultilocusUnphasedGenotype mug = GLStringUtilities.convertToMug(linkedGLString.getGLString());
assertNotNull(mug);
Sample sample = LinkageDisequilibriumAnalyzer.detectLinkages(mug);
assertNotNull(sample);
}
}
use of org.dash.valid.gl.LinkageDisequilibriumGenotypeList in project ImmunogeneticDataTools by nmdp-bioinformatics.
the class GLStringTest method testDRB345AppearsHomozygous.
@Test
public void testDRB345AppearsHomozygous() throws IOException {
assertFalse(glString.hasHomozygous(Locus.HLA_DRB4));
LinkageDisequilibriumGenotypeList simpleDRB4String = new LinkageDisequilibriumGenotypeList("HOMOZYGOUS-DRB4", SIMPLE_DRB4_STRING);
assertTrue(simpleDRB4String.hasHomozygous(Locus.HLA_DRB4));
LinkageDisequilibriumGenotypeList homozygousCString = new LinkageDisequilibriumGenotypeList("HOMOZYGOUS-C", HOMOZYGOUS_C_STRING);
assertTrue(homozygousCString.hasHomozygous(Locus.HLA_C));
}
use of org.dash.valid.gl.LinkageDisequilibriumGenotypeList in project ImmunogeneticDataTools by nmdp-bioinformatics.
the class GLStringUtilitiesTest method testTabDelimitedGLStringFile.
@Test
public void testTabDelimitedGLStringFile() {
List<LinkageDisequilibriumGenotypeList> glStrings = GLStringUtilities.readGLStringFile("tabDelimitedExample.txt");
for (LinkageDisequilibriumGenotypeList linkedGLString : glStrings) {
assertTrue(TAB_DELIMITED.equals(linkedGLString.getId()));
assertTrue(MY_NOTE.equals(linkedGLString.getNote()));
}
}
use of org.dash.valid.gl.LinkageDisequilibriumGenotypeList in project ImmunogeneticDataTools by nmdp-bioinformatics.
the class LinkageDisequilibriumAnalyzer method analyzeGLStringFile.
/**
* @param filename
*/
public static void analyzeGLStringFile(String filename) throws IOException {
List<LinkageDisequilibriumGenotypeList> glStrings = GLStringUtilities.readGLStringFile(filename);
List<Sample> samplesList = null;
samplesList = detectLinkages(glStrings);
for (Sample sample : samplesList) {
DetectedLinkageFindings findings = sample.getFindings();
LinkageDisequilibriumWriter.getInstance().reportDetectedLinkages(findings);
HaplotypePairWriter.getInstance().reportDetectedLinkages(findings);
CommonWellDocumentedWriter.getInstance().reportCommonWellDocumented(findings);
DetectedFindingsWriter.getInstance().reportDetectedFindings(findings);
}
SamplesList allSamples = new SamplesList();
allSamples.setSamples(samplesList);
SummaryWriter.getInstance().reportDetectedLinkages(allSamples);
}
Aggregations