-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #39 from cBioPortal/inc-seg
(7/7) RFC79: Implement incremental upload of CNA segmented data
- Loading branch information
Showing
14 changed files
with
259 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
121 changes: 121 additions & 0 deletions
121
...c/cbio/portal/integrationTest/incremental/TestIncrementalCopyNumberSegmentDataImport.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
/* | ||
* This file is part of cBioPortal. | ||
* | ||
* cBioPortal is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as | ||
* published by the Free Software Foundation, either version 3 of the | ||
* License. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package org.mskcc.cbio.portal.integrationTest.incremental; | ||
|
||
import org.junit.Before; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.mskcc.cbio.portal.dao.DaoCancerStudy; | ||
import org.mskcc.cbio.portal.dao.DaoClinicalData; | ||
import org.mskcc.cbio.portal.dao.DaoCopyNumberSegment; | ||
import org.mskcc.cbio.portal.dao.DaoCopyNumberSegmentFile; | ||
import org.mskcc.cbio.portal.dao.DaoException; | ||
import org.mskcc.cbio.portal.dao.DaoSample; | ||
import org.mskcc.cbio.portal.dao.MySQLbulkLoader; | ||
import org.mskcc.cbio.portal.model.CancerStudy; | ||
import org.mskcc.cbio.portal.model.ClinicalData; | ||
import org.mskcc.cbio.portal.model.CopyNumberSegment; | ||
import org.mskcc.cbio.portal.model.CopyNumberSegmentFile; | ||
import org.mskcc.cbio.portal.model.Sample; | ||
import org.mskcc.cbio.portal.scripts.ImportCopyNumberSegmentData; | ||
import org.springframework.test.annotation.Rollback; | ||
import org.springframework.test.context.ContextConfiguration; | ||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
import java.io.File; | ||
import java.util.List; | ||
import java.util.Set; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.assertNotNull; | ||
|
||
/** | ||
* Tests Incremental Import of CNA segmented data. | ||
* | ||
* @author Ruslan Forostianov | ||
* @author Pieter Lukasse | ||
*/ | ||
@RunWith(SpringJUnit4ClassRunner.class) | ||
@ContextConfiguration(locations = { "classpath:/applicationContext-dao.xml" }) | ||
@Rollback | ||
@Transactional | ||
public class TestIncrementalCopyNumberSegmentDataImport { | ||
|
||
/** | ||
* Test incremental upload of CNA SEG data | ||
*/ | ||
@Test | ||
public void testIncrementalUpload() throws DaoException { | ||
String segSampleId = "TCGA-A1-A0SE-01"; | ||
Sample segDataSample = DaoSample.getSampleByCancerStudyAndSampleId(cancerStudy.getInternalId(), segSampleId); | ||
|
||
CopyNumberSegmentFile copyNumberSegmentFile = new CopyNumberSegmentFile(); | ||
copyNumberSegmentFile.cancerStudyId = cancerStudy.getInternalId(); | ||
copyNumberSegmentFile.referenceGenomeId = CopyNumberSegmentFile.ReferenceGenomeId.hg19; | ||
copyNumberSegmentFile.segFileId = 1; | ||
copyNumberSegmentFile.filename = "test_file.seg"; | ||
copyNumberSegmentFile.description = "test seg file description"; | ||
DaoCopyNumberSegmentFile.addCopyNumberSegmentFile(copyNumberSegmentFile); | ||
DaoClinicalData.addSampleDatum(segDataSample.getInternalId(), "FRACTION_GENOME_ALTERED", "TEST"); | ||
MySQLbulkLoader.bulkLoadOn(); | ||
CopyNumberSegment copyNumberSegment = new CopyNumberSegment( | ||
cancerStudy.getInternalId(), | ||
segDataSample.getInternalId(), | ||
"1", | ||
3218610, | ||
95674710, | ||
100, | ||
0.01); | ||
copyNumberSegment.setSegId(1L); | ||
DaoCopyNumberSegment.addCopyNumberSegment(copyNumberSegment); | ||
MySQLbulkLoader.flushAll(); | ||
|
||
File dataFolder = new File("src/test/resources/incremental/copy_number_alteration/"); | ||
File metaFile = new File(dataFolder, "meta_cna_seg.txt"); | ||
File dataFile = new File(dataFolder, "data_cna.seg"); | ||
|
||
ImportCopyNumberSegmentData importCnaSegData = new ImportCopyNumberSegmentData(new String[] { | ||
"--loadMode", "bulkLoad", | ||
"--meta", metaFile.getAbsolutePath(), | ||
"--data", dataFile.getAbsolutePath(), | ||
"--overwrite-existing", | ||
}); | ||
importCnaSegData.run(); | ||
|
||
CopyNumberSegmentFile fetchedCopyNumberSegmentFile = DaoCopyNumberSegmentFile.getCopyNumberSegmentFile(cancerStudy.getInternalId()); | ||
assertNotNull(fetchedCopyNumberSegmentFile); | ||
assertEquals("test_file.seg", fetchedCopyNumberSegmentFile.filename); | ||
List<CopyNumberSegment> cnaSegments = DaoCopyNumberSegment | ||
.getSegmentForASample(segDataSample.getInternalId(), cancerStudy.getInternalId()); | ||
assertEquals(9, cnaSegments.size()); | ||
List<ClinicalData> clinicalData = DaoClinicalData.getSampleData(cancerStudy.getInternalId(), Set.of(segSampleId)); | ||
ClinicalData fractionGenomeAltered = clinicalData.stream() | ||
.filter(cd -> "FRACTION_GENOME_ALTERED".equals(cd.getAttrId())).findFirst().get(); | ||
assertEquals("0.0000", fractionGenomeAltered.getAttrVal()); | ||
} | ||
|
||
public static final String STUDY_ID = "study_tcga_pub"; | ||
private CancerStudy cancerStudy; | ||
|
||
@Before | ||
public void setUp() throws DaoException { | ||
cancerStudy = DaoCancerStudy.getCancerStudyByStableId(STUDY_ID); | ||
} | ||
|
||
} |
10 changes: 10 additions & 0 deletions
10
src/test/resources/incremental/copy_number_alteration/data_cna.seg
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
ID chrom loc.start loc.end num.mark seg.mean | ||
TCGA-A1-A0SE-01 1 3218610 95674710 53225 0.0055 | ||
TCGA-A1-A0SE-01 1 95676511 95676518 2 -1.6636 | ||
TCGA-A1-A0SE-01 1 95680124 167057183 24886 0.0053 | ||
TCGA-A1-A0SE-01 1 167057495 167059336 3 -1.0999 | ||
TCGA-A1-A0SE-01 1 167059760 181602002 9213 -8e-04 | ||
TCGA-A1-A0SE-01 1 181603120 181609567 6 -1.2009 | ||
TCGA-A1-A0SE-01 1 181610685 201473647 12002 0.0055 | ||
TCGA-A1-A0SE-01 1 201474400 201474544 2 -1.4235 | ||
TCGA-A1-A0SE-01 1 201475220 247813706 29781 -4e-04 |
Oops, something went wrong.