Skip to content

Commit

Permalink
Merge pull request #64 from ao508/sample-type-f
Browse files Browse the repository at this point in the history
Default F sample type abbreviation
  • Loading branch information
ao508 authored May 5, 2023
2 parents 7b53064 + 6e7988d commit 09d6606
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,6 @@ Status generateSampleStatus(String requestId, IgoSampleManifest sampleManifest,
Status generateSampleStatus(SampleMetadata sampleMetadata,
List<SampleMetadata> existingSamples) throws JsonProcessingException;
Boolean igoSampleRequiresLabelUpdate(String newCmoLabel, String existingCmoLabel);
String resolveSampleTypeAbbreviation(String specimenTypeValue, String sampleOriginValue,
String cmoSampleClassValue);
}
Original file line number Diff line number Diff line change
Expand Up @@ -172,11 +172,6 @@ public String generateCmoSampleLabel(String requestId, IgoSampleManifest sampleM

// resolve sample type abbreviation
String sampleTypeAbbreviation = resolveSampleTypeAbbreviation(sampleManifest);
if (sampleTypeAbbreviation == null) {
LOG.error("Could not resolve sample type abbreviation from specimen type,"
+ " sample origin, or sample class: " + sampleManifest.toString());
return null;
}

// resolve the sample counter value to use for the cmo label
Integer sampleCounter = resolveSampleIncrementValue(sampleManifest.getIgoId(), existingSamples);
Expand Down Expand Up @@ -253,7 +248,9 @@ public Status generateSampleStatus(String requestId, IgoSampleManifest sampleMan
Status sampleStatus = new Status();
Map<String, String> validationReport = new HashMap<>();

if (resolveSampleTypeAbbreviation(sampleManifest) == null) {
String sampleTypeAbbreviation = resolveSampleTypeAbbreviation(sampleManifest);
if (sampleTypeAbbreviation == null
|| sampleTypeAbbreviation.equals("F")) {
validationReport.put("sample type abbreviation",
"could not resolve based on specimenType, sampleOrigin, or sampleClass");
}
Expand All @@ -276,8 +273,10 @@ public Status generateSampleStatus(SampleMetadata sampleMetadata,
Status sampleStatus = new Status();
Map<String, String> validationReport = new HashMap<>();

if (resolveSampleTypeAbbreviation(sampleMetadata.getSampleClass(),
sampleMetadata.getSampleOrigin(), sampleMetadata.getSampleType()) == null) {
String sampleTypeAbbreviation = resolveSampleTypeAbbreviation(sampleMetadata.getSampleClass(),
sampleMetadata.getSampleOrigin(), sampleMetadata.getSampleType());
if (sampleTypeAbbreviation == null
|| sampleTypeAbbreviation.equals("F")) {
validationReport.put("sample type abbreviation",
"could not resolve based on specimenType, sampleOrigin, or sampleClass");
}
Expand Down Expand Up @@ -361,7 +360,8 @@ private String resolveNucleicAcidAbbreviation(IgoSampleManifest sampleManifest)
return resolveNucleicAcidAbbreviation(sampleTypeString, recipe, naToExtract);
}

private String resolveSampleTypeAbbreviation(String specimenTypeValue, String sampleOriginValue,
@Override
public String resolveSampleTypeAbbreviation(String specimenTypeValue, String sampleOriginValue,
String cmoSampleClassValue) {
try {
SpecimenType specimenType = SpecimenType.fromValue(specimenTypeValue);
Expand Down Expand Up @@ -389,7 +389,13 @@ private String resolveSampleTypeAbbreviation(String specimenTypeValue, String sa

// if abbreviation is still not resolved then try to resolve from sample class
CmoSampleClass sampleClass = CmoSampleClass.fromValue(cmoSampleClassValue);
return SAMPLE_CLASS_ABBREV_MAP.get(sampleClass);
String sampleTypeAbbreviation = SAMPLE_CLASS_ABBREV_MAP.get(sampleClass);
if (sampleTypeAbbreviation == null) {
LOG.warn("Could not resolve sample type abbreviation from specimen type,"
+ " sample origin, or sample class - using default 'F' ");
return "F";
}
return sampleTypeAbbreviation;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import org.mskcc.smile.model.igo.IgoSampleManifest;
import org.mskcc.smile.service.CmoLabelGeneratorService;
import org.mskcc.smile.service.MessageHandlingService;
import org.mskcc.smile.service.util.RequestStatusLogger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
Expand Down
11 changes: 9 additions & 2 deletions src/test/java/org/mskcc/smile/CmoLabelGeneratorServiceTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ public void testCmoLabelGenForExistingSampleWithPatientCorrection()
// if the cmo label before the update is C-MP789JR-X001-d
Assert.assertEquals("C-newPatient-X001-d02", newCmoLabel);


Status sampleStatus = cmoLabelGeneratorService.generateSampleStatus(
updatedSample, existingSamples);
Assert.assertEquals(Boolean.TRUE, sampleStatus.getValidationStatus());
Expand Down Expand Up @@ -226,7 +226,7 @@ public void testCmoLabelGenForSampleWithOtherSpecimenType()
// should return null string
String newCmoLabel = cmoLabelGeneratorService.generateCmoSampleLabel(
updatedSample, existingSamples);
Assert.assertNull(newCmoLabel);
Assert.assertEquals("C-MP789JR-F001-d01", newCmoLabel);

Status sampleStatus = cmoLabelGeneratorService.generateSampleStatus(
updatedSample, existingSamples);
Expand Down Expand Up @@ -270,6 +270,13 @@ public void testCmoCelllineLabelGenerationUpdates() {
sampleUpdatedNaExtractLabel, sampleExpectedLabel));
}

@Test
public void testDefaultSampleTypeAbbreviation() {
String sampleTypeAbbrev = cmoLabelGeneratorService.resolveSampleTypeAbbreviation("RapidAutopsy",
"Cerebrospinal Fluid", "Other");
Assert.assertTrue(sampleTypeAbbrev.equals("F"));
}

private IgoSampleManifest getSampleMetadata(String igoId, String cmoPatientId,
SpecimenType specimenType, NucleicAcid naToExtract, String investigatorSampleId) {
IgoSampleManifest sample = new IgoSampleManifest();
Expand Down

0 comments on commit 09d6606

Please sign in to comment.