Skip to content

Commit ab4b09c

Browse files
authored
Handle dual extraction sample labels (#131)
Added logic for resolving cmo sample labels for samples that are dual extractions. These labels will fall back on tumorOrNormal to resolve the sample type abbreviation Signed-off-by: Angelica Ochoa <15623749+ao508@users.noreply.github.com>
1 parent b3df67b commit ab4b09c

File tree

3 files changed

+135
-51
lines changed

3 files changed

+135
-51
lines changed

src/main/java/org/mskcc/smile/service/impl/CmoLabelGeneratorServiceImpl.java

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import org.mskcc.smile.commons.enums.SampleOrigin;
2626
import org.mskcc.smile.commons.enums.SampleType;
2727
import org.mskcc.smile.commons.enums.SpecimenType;
28+
import org.mskcc.smile.commons.enums.TumorNormalType;
2829
import org.mskcc.smile.service.CmoLabelGeneratorService;
2930
import org.mskcc.smile.service.util.CmoLabelParts;
3031
import org.springframework.beans.factory.annotation.Autowired;
@@ -598,16 +599,39 @@ public String resolveSampleTypeAbbreviation(CmoLabelParts sampleLabelParts) {
598599
return CFDNA_ABBREV_DEFAULT;
599600
}
600601
} catch (Exception e) {
601-
// happens if cmoSampleClassValue is not found in CmoSampleClass
602-
// nothing to do here since since sampleTypeAbbreviation
603-
// is initialized to default 'F'
602+
LOG.warn("Could not resolve sample type abbreviation from sampleType (IGO cmoSampleClass)"
603+
+ " - checking if sample is a dual extraction.");
604604
}
605605

606+
// check if sample is dual extraction if sample type abbreviation is still not resolved
607+
try {
608+
NucleicAcid na = NucleicAcid.fromString(sampleLabelParts.getNaToExtract());
609+
if (na.equals(NucleicAcid.DNA_AND_RNA)) {
610+
TumorNormalType tn = TumorNormalType.getByValue(sampleLabelParts.getTumorOrNormal());
611+
switch (tn) {
612+
case TUMOR -> {
613+
return "T";
614+
}
615+
case NORMAL -> {
616+
return "N";
617+
}
618+
default -> LOG.warn("Sample identified as a dual extraction but could not resolve"
619+
+ " value for tumorOrNormal: " + sampleLabelParts.getTumorOrNormal());
620+
}
621+
}
622+
} catch (Exception e) {
623+
// happens if naToExtract cannot be resolved - nothing to do since
624+
// sampleTypeAbbreviation will default to 'F'
625+
}
626+
627+
// log sample details for failed sample type abbreviation
606628
if (sampleTypeAbbreviation.equalsIgnoreCase("F")) {
607629
LOG.warn("Could not resolve sample type abbreviation from sample class (igo specimen type),"
608-
+ " sample origin, or sample type (igo cmo sample class) - using default 'F': ("
630+
+ " sample origin, or sample type (igo cmo sample class), and did not identify sample"
631+
+ " as a dual extraction - using default 'F': ("
609632
+ sampleLabelParts.getSampleClass() + ", " + sampleLabelParts.getSampleOrigin()
610-
+ ", " + sampleLabelParts.getSampleType() + ")");
633+
+ ", " + sampleLabelParts.getSampleType() + sampleLabelParts.getNaToExtract() + ", "
634+
+ sampleLabelParts.getTumorOrNormal() + ")");
611635
}
612636
return sampleTypeAbbreviation;
613637
}

src/main/java/org/mskcc/smile/service/util/CmoLabelParts.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ public class CmoLabelParts implements Serializable, Cloneable {
3131
@JsonIgnore
3232
private String origSampleJsonStr;
3333
private String cmoSampleName; // igo/smile => cmoSampleName
34+
private String tumorOrNormal; // igo/smile => tumorOrNormal
3435

3536
public CmoLabelParts() {}
3637

@@ -49,6 +50,7 @@ public CmoLabelParts(Map<String, Object> sampleMap, String requestId) throws Jso
4950
this.investigatorSampleId = getString(sampleMap, "investigatorSampleId");
5051
this.baitSet = getString(sampleMap, "baitSet");
5152
this.cmoSampleName = getString(sampleMap, "cmoSampleName");
53+
this.tumorOrNormal = getString(sampleMap, "tumorOrNormal");
5254

5355
Map<String, Object> cmoSampleIdFields
5456
= mapper.convertValue(sampleMap.get("cmoSampleIdFields"), Map.class);
@@ -284,6 +286,20 @@ public void setCmoSampleName(String cmoSampleName) {
284286
this.cmoSampleName = cmoSampleName;
285287
}
286288

289+
/**
290+
* @return the tumorOrNormal
291+
*/
292+
public String getTumorOrNormal() {
293+
return tumorOrNormal;
294+
}
295+
296+
/**
297+
* @param tumorOrNormal the tumorOrNormal to set
298+
*/
299+
public void setTumorOrNormal(String tumorOrNormal) {
300+
this.tumorOrNormal = tumorOrNormal;
301+
}
302+
287303
private String getString(Map<String, Object> map, String key) {
288304
return (map == null || !map.containsKey(key) || map.get(key) == null)
289305
? null : map.get(key).toString();

0 commit comments

Comments
 (0)