Search in sources :

Example 1 with Sample

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

the class GenotypesApiController method submitGenotypes.

@Override
public ResponseEntity<Samples> submitGenotypes(@ApiParam(value = "Genotypes", required = true) @Valid @RequestBody Genotypes genotypes) {
    List<Genotype> genotypeList = genotypes.getGenotype();
    Samples samples = new Samples();
    SampleData sampleData = null;
    for (Genotype genotype : genotypeList) {
        LinkageDisequilibriumGenotypeList linkedGLString = GLStringUtilities.inflateGenotypeList(genotype.getId(), genotype.getGlString(), null);
        Sample sample = LinkageDisequilibriumAnalyzer.detectLinkages(linkedGLString);
        sampleData = populateSwaggerObject(sample);
        samples.addSampleItem(sampleData);
    }
    return ResponseEntity.ok(samples);
}
Also used : LinkageDisequilibriumGenotypeList(org.dash.valid.gl.LinkageDisequilibriumGenotypeList) Samples(io.swagger.model.Samples) SampleData(io.swagger.model.SampleData) Sample(org.dash.valid.Sample) Genotype(io.swagger.model.Genotype)

Example 2 with Sample

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

the class LinkageDisequilibriumAnalyzerTest method testLinkageReportingInlineGLString.

@Test
public void testLinkageReportingInlineGLString() throws IOException {
    String fullyQualified = GLStringUtilities.fullyQualifyGLString("HLA-A*11:01:01+HLA-A*24:02:01:01/HLA-A*24:02:01:02L/HLA-A*24:02:01:03^HLA-B*18:01:01:01/HLA-B*18:01:01:02/HLA-B*18:51+HLA-B*53:01:01^HLA-C*04:01:01:01/HLA-C*04:01:01:02/HLA-C*04:01:01:03/HLA-C*04:01:01:04/HLA-C*04:01:01:05/HLA-C*04:20/HLA-C*04:117+HLA-C*12:03:01:01/HLA-C*12:03:01:02/HLA-C*12:34^HLA-DPA1*01:03:01:01/HLA-DPA1*01:03:01:02/HLA-DPA1*01:03:01:03/HLA-DPA1*01:03:01:04/HLA-DPA1*01:03:01:05+HLA-DPA1*02:01:01^HLA-DPB1*02:01:02+HLA-DPB1*09:01^HLA-DQA1*01:02:01:01/HLA-DQA1*01:02:01:02/HLA-DQA1*01:02:01:03/HLA-DQA1*01:02:01:04/HLA-DQA1*01:11+HLA-DQA1*03:01:01^HLA-DQB1*03:05:01+HLA-DQB1*06:09^HLA-DRB1*11:04:01+HLA-DRB1*13:02:01^HLA-DRB3*02:02:01:01/HLA-DRB3*02:02:01:02+HLA-DRB3*03:01:01");
    MultilocusUnphasedGenotype mug = GLStringUtilities.convertToMug(fullyQualified);
    Sample sample = LinkageDisequilibriumAnalyzer.detectLinkages(mug);
    assertNotNull(sample);
}
Also used : Sample(org.dash.valid.Sample) MultilocusUnphasedGenotype(org.nmdp.gl.MultilocusUnphasedGenotype) Test(org.junit.Test)

Example 3 with Sample

use of org.dash.valid.Sample 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 4 with Sample

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

the class ValidateLdGlstrings method read.

static ListMultimap<String, SubjectMug> read(final File file) throws IOException {
    BufferedReader reader = null;
    final ListMultimap<String, SubjectMug> subjectmugs = ArrayListMultimap.create();
    final SubjectMug.Builder builder = SubjectMug.builder();
    try {
        reader = reader(file);
        CharStreams.readLines(reader, new LineProcessor<Void>() {

            private int count = 0;

            @Override
            public boolean processLine(final String line) throws IOException {
                String[] tokens = line.split("\t");
                if (tokens.length < 2) {
                    throw new IOException("illegal format, expected at least 2 columns, found " + tokens.length + "\nline=" + line);
                }
                String fullyQualified = GLStringUtilities.fullyQualifyGLString(tokens[1]);
                MultilocusUnphasedGenotype mug = GLStringUtilities.convertToMug(fullyQualified);
                Sample sample = LinkageDisequilibriumAnalyzer.detectLinkages(mug);
                DetectedLinkageFindings findings = sample.getFindings();
                Float minimumDifference = findings.getMinimumDifference(Locus.FIVE_LOCUS);
                minimumDifference = minimumDifference == null ? 0 : minimumDifference;
                SubjectMug subjectMug = builder.reset().withSample(tokens[0]).withGlstring(tokens[1]).withMug(mug).withFindings(findings).withMinimumDifference(minimumDifference).build();
                subjectmugs.put(subjectMug.sample(), subjectMug);
                count++;
                return true;
            }

            @Override
            public Void getResult() {
                return null;
            }
        });
        return subjectmugs;
    } finally {
        try {
            reader.close();
        } catch (Exception e) {
        // ignore
        }
    }
}
Also used : Sample(org.dash.valid.Sample) MultilocusUnphasedGenotype(org.nmdp.gl.MultilocusUnphasedGenotype) IOException(java.io.IOException) IOException(java.io.IOException) CommandLineParseException(org.dishevelled.commandline.CommandLineParseException) DetectedLinkageFindings(org.dash.valid.report.DetectedLinkageFindings) BufferedReader(java.io.BufferedReader)

Example 5 with Sample

use of org.dash.valid.Sample 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

Sample (org.dash.valid.Sample)7 Test (org.junit.Test)4 LinkageDisequilibriumGenotypeList (org.dash.valid.gl.LinkageDisequilibriumGenotypeList)3 MultilocusUnphasedGenotype (org.nmdp.gl.MultilocusUnphasedGenotype)3 BufferedReader (java.io.BufferedReader)2 File (java.io.File)2 DetectedLinkageFindings (org.dash.valid.report.DetectedLinkageFindings)2 Genotype (io.swagger.model.Genotype)1 SampleData (io.swagger.model.SampleData)1 Samples (io.swagger.model.Samples)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 InputStreamReader (java.io.InputStreamReader)1 PrintWriter (java.io.PrintWriter)1 Haplotype (org.dash.valid.gl.haplo.Haplotype)1 SamplesList (org.dash.valid.report.SamplesList)1 CommandLineParseException (org.dishevelled.commandline.CommandLineParseException)1