use of org.cbioportal.cmo.pipelines.cvr.model.staging.LinkedMskimpactCaseRecord in project cmo-pipelines by knowledgesystems.
the class LinkedMskimpactCaseReader method loadExistingLinkedIds.
private void loadExistingLinkedIds() {
File stagingFile = new File(stagingDirectory, cvrUtilities.CORRESPONDING_ID_FILE);
if (!stagingFile.exists()) {
LOG.warn("File does not exist - skipping data loading from linked ARCHER samples file: " + stagingFile.getName());
return;
}
LOG.info("Loading linked ARCHER sample data from: " + stagingFile.getName());
DelimitedLineTokenizer tokenizer = new DelimitedLineTokenizer(DelimitedLineTokenizer.DELIMITER_TAB);
DefaultLineMapper<LinkedMskimpactCaseRecord> mapper = new DefaultLineMapper<>();
mapper.setLineTokenizer(tokenizer);
mapper.setFieldSetMapper(new LinkedImpactCaseFieldSetMapper());
FlatFileItemReader<LinkedMskimpactCaseRecord> reader = new FlatFileItemReader<>();
reader.setResource(new FileSystemResource(stagingFile));
reader.setLineMapper(mapper);
reader.setLinesToSkip(1);
reader.open(new ExecutionContext());
try {
LinkedMskimpactCaseRecord to_add;
while ((to_add = reader.read()) != null) {
// only add samples that are not in the new dmp sample list
if (!cvrSampleListUtil.getNewDmpSamples().contains(to_add.getSAMPLE_ID())) {
compiledLinkedIdsMap.put(to_add.getSAMPLE_ID(), to_add);
}
// keep a backup in case JSON returned dropped all "linked_mskimpact_case" data
existingLinkedIdsMap.put(to_add.getSAMPLE_ID(), to_add);
}
} catch (Exception e) {
LOG.error("Error reading linked ARCHER sample data from file: " + stagingFile.getName());
throw new ItemStreamException(e);
} finally {
reader.close();
}
}
use of org.cbioportal.cmo.pipelines.cvr.model.staging.LinkedMskimpactCaseRecord in project cmo-pipelines by knowledgesystems.
the class LinkedMskimpactCaseReader method loadNewLinkedIds.
private void loadNewLinkedIds() {
CVRData cvrData = new CVRData();
// load cvr data from cvr_data.json file
File cvrFile = new File(privateDirectory, cvrUtilities.CVR_FILE);
try {
cvrData = cvrUtilities.readJson(cvrFile);
} catch (IOException e) {
LOG.error("Error reading file: " + cvrFile.getName());
throw new ItemStreamException(e);
}
for (CVRMergedResult result : cvrData.getResults()) {
String linkedId = result.getMetaData().getLinkedMskimpactCase();
if (!Strings.isNullOrEmpty(linkedId) && !linkedId.equals("NA")) {
compiledLinkedIdsMap.put(result.getMetaData().getDmpSampleId(), new LinkedMskimpactCaseRecord(result.getMetaData().getDmpSampleId(), linkedId));
}
}
}
use of org.cbioportal.cmo.pipelines.cvr.model.staging.LinkedMskimpactCaseRecord in project cmo-pipelines by knowledgesystems.
the class LinkedImpactCaseFieldSetMapper method mapFieldSet.
@Override
public LinkedMskimpactCaseRecord mapFieldSet(FieldSet fs) throws BindException {
LinkedMskimpactCaseRecord record = new LinkedMskimpactCaseRecord();
List<String> fields = LinkedMskimpactCaseRecord.getFieldNames();
for (int i = 0; i < fields.size(); i++) {
String field = fields.get(i);
try {
record.getClass().getMethod("set" + field, String.class).invoke(record, fs.readString(i));
} catch (Exception e) {
if (e.getClass().equals(NoSuchMethodException.class)) {
log.info("No set method exists for " + field);
}
}
}
return record;
}
Aggregations