Search in sources :

Example 6 with LinkageDisequilibriumGenotypeList

use of org.dash.valid.gl.LinkageDisequilibriumGenotypeList in project ImmunogeneticDataTools by nmdp-bioinformatics.

the class LinkageDisequilibriumAnalyzer method detectLinkages.

public static Sample detectLinkages(MultilocusUnphasedGenotype mug) {
    LinkageDisequilibriumGenotypeList linkedGLString = new LinkageDisequilibriumGenotypeList(mug.getId(), mug);
    Sample sample = detectLinkages(linkedGLString);
    return sample;
}
Also used : LinkageDisequilibriumGenotypeList(org.dash.valid.gl.LinkageDisequilibriumGenotypeList)

Example 7 with LinkageDisequilibriumGenotypeList

use of org.dash.valid.gl.LinkageDisequilibriumGenotypeList in project ImmunogeneticDataTools by nmdp-bioinformatics.

the class LinkageDisequilibriumAnalyzer method detectLinkages.

/**
 * @param glStrings
 * @throws IOException
 * @throws SecurityException
 */
private static List<Sample> detectLinkages(List<LinkageDisequilibriumGenotypeList> glStrings) {
    List<Sample> samplesList = new ArrayList<Sample>();
    int idx = 1;
    for (LinkageDisequilibriumGenotypeList linkedGLString : glStrings) {
        List<Haplotype> knownHaplotypes = GLStringUtilities.buildHaplotypes(linkedGLString);
        LOGGER.info("Processing gl string " + idx + " of " + glStrings.size() + " (" + (idx * 100) / glStrings.size() + "%)");
        idx++;
        if (knownHaplotypes.size() > 0) {
            samplesList.add(HLALinkageDisequilibrium.hasLinkageDisequilibrium(linkedGLString, knownHaplotypes));
        } else {
            boolean homozygousOnly = Boolean.TRUE.equals(System.getProperty("org.dash.homozygous")) ? Boolean.TRUE : Boolean.FALSE;
            // TODO:  Actually implement by skipping the record
            if (!linkedGLString.checkAmbiguitiesThresholds()) {
                LOGGER.info("GL String contains an unusual number of ambiguities, proteins and/or uncommon alleles");
            }
            if (homozygousOnly && !linkedGLString.hasHomozygous(LinkagesLoader.getInstance().getLoci())) {
                LOGGER.info("Only checking for homozygous.  GL String contains no homozygous typings for the loci in question.  Bypassing record.");
                continue;
            }
            samplesList.add(detectLinkages(linkedGLString));
        }
    }
    return samplesList;
}
Also used : LinkageDisequilibriumGenotypeList(org.dash.valid.gl.LinkageDisequilibriumGenotypeList) ArrayList(java.util.ArrayList) Haplotype(org.dash.valid.gl.haplo.Haplotype)

Example 8 with LinkageDisequilibriumGenotypeList

use of org.dash.valid.gl.LinkageDisequilibriumGenotypeList in project ImmunogeneticDataTools by nmdp-bioinformatics.

the class LinkageDisequilibriumGenotypeListTest method testHaplotypePairs.

@Test
public void testHaplotypePairs() throws IOException {
    LinkageDisequilibriumGenotypeList genotypeList = new LinkageDisequilibriumGenotypeList("HaplotypePairs", TEST_BC_PAIRS);
    Set<Locus> loci = new HashSet<Locus>();
    loci.add(Locus.HLA_B);
    loci.add(Locus.HLA_C);
    Set<MultiLocusHaplotype> possibleHaplotypes = genotypeList.constructPossibleHaplotypes(loci);
    Set<HaplotypePair> linkedPairs = new HaplotypePairSet(new HaplotypePairComparator());
    for (Haplotype haplotype1 : possibleHaplotypes) {
        for (Haplotype haplotype2 : possibleHaplotypes) {
            if ((!genotypeList.hasHomozygous(Locus.HLA_B) && haplotype1.getAlleles(Locus.HLA_B).containsAll(haplotype2.getAlleles(Locus.HLA_B))) || (!genotypeList.hasHomozygous(Locus.HLA_C) && haplotype1.getAlleles(Locus.HLA_C).containsAll(haplotype2.getAlleles(Locus.HLA_C)))) {
                continue;
            }
            HaplotypePair haplotypePair = new HaplotypePair(haplotype1, haplotype2);
            linkedPairs.add(haplotypePair);
        }
    }
    for (HaplotypePair pair : linkedPairs) {
        Haplotype haplotype1 = pair.getHaplotypes().get(0);
        assertTrue(haplotype1 instanceof MultiLocusHaplotype);
        Haplotype haplotype2 = pair.getHaplotypes().get(1);
        assertTrue(haplotype2 instanceof MultiLocusHaplotype);
        assertTrue((haplotype1.getAlleles(Locus.HLA_B).contains(B0704) && haplotype2.getAlleles(Locus.HLA_B).contains(B4403)) || (haplotype1.getAlleles(Locus.HLA_B).contains(B4403) && haplotype2.getAlleles(Locus.HLA_B).contains(B0704)));
        assertTrue((haplotype1.getAlleles(Locus.HLA_C).contains(C0702) && haplotype2.getAlleles(Locus.HLA_C).contains(C1203)) || (haplotype1.getAlleles(Locus.HLA_C).contains(C1203) && haplotype2.getAlleles(Locus.HLA_C).contains(C0702)));
        assertFalse(haplotype1.getAlleles(Locus.HLA_B).contains(B0704) && haplotype2.getAlleles(Locus.HLA_B).contains(B0704));
        assertFalse(haplotype1.getAlleles(Locus.HLA_B).contains(B4403) && haplotype2.getAlleles(Locus.HLA_B).contains(B4403));
        assertFalse(haplotype1.getAlleles(Locus.HLA_C).contains(C0702) && haplotype2.getAlleles(Locus.HLA_C).contains(C0702));
        assertFalse(haplotype1.getAlleles(Locus.HLA_C).contains(C1203) && haplotype2.getAlleles(Locus.HLA_C).contains(C1203));
    }
}
Also used : LinkageDisequilibriumGenotypeList(org.dash.valid.gl.LinkageDisequilibriumGenotypeList) HaplotypePair(org.dash.valid.gl.haplo.HaplotypePair) HaplotypePairSet(org.dash.valid.gl.haplo.HaplotypePairSet) Locus(org.dash.valid.Locus) MultiLocusHaplotype(org.dash.valid.gl.haplo.MultiLocusHaplotype) 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) Test(org.junit.Test)

Example 9 with LinkageDisequilibriumGenotypeList

use of org.dash.valid.gl.LinkageDisequilibriumGenotypeList in project ImmunogeneticDataTools by nmdp-bioinformatics.

the class LinkageDisequilibriumAnalyzerTest method testPhasedGenotypeList.

@Test
public void testPhasedGenotypeList() throws IOException {
    System.setProperty(Frequencies.FREQUENCIES_PROPERTY, Frequencies.NMDP.getShortName());
    String fullyQualified = GLStringUtilities.fullyQualifyGLString("HLA-A*24:02:01:01~HLA-C*04:01:01:06~HLA-B*35:02:01~HLA-DRB3*02:02:01:02~HLA-DRB1*11:01:01:01~HLA-DQA1*05:05:01:01/HLA-DQA1*05:05:01:02~HLA-DQB1*03:01:01:03~HLA-DPA1*01:03:01:01~HLA-DPB1*05:01:01+HLA-A*11:01:01:01~HLA-C*12:03:01:01~HLA-B*35:03:01~HLA-DRB3*02:02:01:01~HLA-DRB1*13:01:01:01/HLA-DRB1*13:01:01:02~HLA-DQA1*01:03:01:02~HLA-DQB1*06:03:01~HLA-DPA1*02:01:01:01~HLA-DPB1*13:01:01/HLA-DPB1*107:01");
    LinkageDisequilibriumGenotypeList glString = new LinkageDisequilibriumGenotypeList("SBCFMW0003", fullyQualified);
    List<Haplotype> knownHaplotypes = GLStringUtilities.buildHaplotypes(glString);
    Sample sample = HLALinkageDisequilibrium.hasLinkageDisequilibrium(glString, knownHaplotypes);
    assertNotNull(sample);
}
Also used : LinkageDisequilibriumGenotypeList(org.dash.valid.gl.LinkageDisequilibriumGenotypeList) Sample(org.dash.valid.Sample) Haplotype(org.dash.valid.gl.haplo.Haplotype) Test(org.junit.Test)

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