Skip to content

Commit

Permalink
Add clinical sample attributes metadata support
Browse files Browse the repository at this point in the history
  • Loading branch information
forus committed Dec 11, 2024
1 parent d8f64f0 commit 5b33f82
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/**
* Represents metadata for a cancer study.
*/
public record CancerStudyMetadata(
public record CancerStudyMetadata (
/**
* The cancer type abbreviation, e.g., "brca". This should be the same cancer type as specified in the meta_cancer_type.txt file, if available. The type can be "mixed" for studies with multiple cancer types.
*/
Expand Down Expand Up @@ -44,7 +44,7 @@ public record CancerStudyMetadata(
Optional<String> groups,

/**
* Set to 'true' if you would like the "All samples" case list to be generated automatically for you. See also Case lists.
* Set to true if you would like the "All samples" case list to be generated automatically for you. See also Case lists.
*/
@JsonProperty("add_global_case_list")
Optional<Boolean> addGlobalCaseList,
Expand All @@ -59,4 +59,4 @@ public record CancerStudyMetadata(
*/
@JsonProperty("reference_genome")
Optional<String> referenceGenome
) {}
) implements StudyRelated {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package org.cbioportal.file.model;

public record ClinicalSampleAttributesMetadata(
String cancerStudyIdentifier,
String dataFilename
) implements GenericStudyDataDescriptor {
public String geneticAlterationType() {
return "CLINICAL";
}

public String datatype() {
return "SAMPLE_ATTRIBUTES";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package org.cbioportal.file.model;

public interface GenericStudyDataDescriptor extends StudyRelated {
String geneticAlterationType();
String datatype();
String dataFilename();
}
5 changes: 5 additions & 0 deletions src/main/java/org/cbioportal/file/model/StudyRelated.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package org.cbioportal.file.model;

public interface StudyRelated {
String cancerStudyIdentifier();
}
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
package org.cbioportal.file.export;

import org.cbioportal.file.model.CancerStudyMetadata;
import org.cbioportal.file.model.ClinicalSampleAttributesMetadata;
import org.junit.Test;

import java.io.StringWriter;
import java.util.Optional;

import static org.junit.Assert.assertEquals;

public class CancerStudyMetadataWriterTest {
public class MetadataWriterTest {

StringWriter output = new StringWriter();
KeyValueConfigurationWriter writer = new KeyValueConfigurationWriter(output);

@Test
public void testAllFields() {
public void testCancerStudyMetadataWriter() {
writer.writeRecord(new CancerStudyMetadata(
"toc",
"study_id1",
Expand All @@ -41,4 +42,17 @@ public void testAllFields() {
reference_genome: hg38
""", output.toString());
}

@Test
public void testClinicalSampleAttributesMetadataWriter() {
writer.writeRecord(new ClinicalSampleAttributesMetadata(
"study_id1",
"data_file.txt"
));

assertEquals("""
cancer_study_identifier: study_id1
data_filename: data_file.txt
""", output.toString());
}
}

0 comments on commit 5b33f82

Please sign in to comment.