Search in sources :

Example 1 with LinkageDisequilibriumGenotypeList

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;
}
Also used : HaplotypePair(org.dash.valid.gl.haplo.HaplotypePair) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) HaplotypePairSet(org.dash.valid.gl.haplo.HaplotypePairSet) ArrayList(java.util.ArrayList) DetectedDisequilibriumElement(org.dash.valid.report.DetectedDisequilibriumElement) DetectedDisequilibriumElement(org.dash.valid.report.DetectedDisequilibriumElement) ArrayList(java.util.ArrayList) LinkageDisequilibriumGenotypeList(org.dash.valid.gl.LinkageDisequilibriumGenotypeList) List(java.util.List) MultiLocusHaplotype(org.dash.valid.gl.haplo.MultiLocusHaplotype) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HaplotypePairComparator(org.dash.valid.gl.haplo.HaplotypePairComparator) Haplotype(org.dash.valid.gl.haplo.Haplotype) MultiLocusHaplotype(org.dash.valid.gl.haplo.MultiLocusHaplotype) HashSet(java.util.HashSet)

Example 2 with LinkageDisequilibriumGenotypeList

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);
    }
}
Also used : LinkageDisequilibriumGenotypeList(org.dash.valid.gl.LinkageDisequilibriumGenotypeList) Sample(org.dash.valid.Sample) MultilocusUnphasedGenotype(org.nmdp.gl.MultilocusUnphasedGenotype) Test(org.junit.Test)

Example 3 with LinkageDisequilibriumGenotypeList

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));
}
Also used : LinkageDisequilibriumGenotypeList(org.dash.valid.gl.LinkageDisequilibriumGenotypeList) Test(org.junit.Test)

Example 4 with LinkageDisequilibriumGenotypeList

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()));
    }
}
Also used : LinkageDisequilibriumGenotypeList(org.dash.valid.gl.LinkageDisequilibriumGenotypeList) Test(org.junit.Test)

Example 5 with LinkageDisequilibriumGenotypeList

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);
}
Also used : LinkageDisequilibriumGenotypeList(org.dash.valid.gl.LinkageDisequilibriumGenotypeList) SamplesList(org.dash.valid.report.SamplesList) DetectedLinkageFindings(org.dash.valid.report.DetectedLinkageFindings)

Aggregations

LinkageDisequilibriumGenotypeList (org.dash.valid.gl.LinkageDisequilibriumGenotypeList)9 Test (org.junit.Test)5 Haplotype (org.dash.valid.gl.haplo.Haplotype)4 ArrayList (java.util.ArrayList)2 HashSet (java.util.HashSet)2 Sample (org.dash.valid.Sample)2 HaplotypePair (org.dash.valid.gl.haplo.HaplotypePair)2 HaplotypePairComparator (org.dash.valid.gl.haplo.HaplotypePairComparator)2 HaplotypePairSet (org.dash.valid.gl.haplo.HaplotypePairSet)2 MultiLocusHaplotype (org.dash.valid.gl.haplo.MultiLocusHaplotype)2 HashMap (java.util.HashMap)1 List (java.util.List)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 Locus (org.dash.valid.Locus)1 DetectedDisequilibriumElement (org.dash.valid.report.DetectedDisequilibriumElement)1 DetectedLinkageFindings (org.dash.valid.report.DetectedLinkageFindings)1 SamplesList (org.dash.valid.report.SamplesList)1 MultilocusUnphasedGenotype (org.nmdp.gl.MultilocusUnphasedGenotype)1