use of org.monarchinitiative.loinc2hpo.io.FromFile in project loinc2hpo by monarch-initiative.
the class Loinc2HpoAnnotationsTabController method importLoincAnnotation.
/**
* This method handles my old and new TSV format
*/
public void importLoincAnnotation() {
logger.debug("Num of annotations in model: " + model.getLoincAnnotationMap().size());
FileChooser chooser = new FileChooser();
chooser.getExtensionFilters().add(new FileChooser.ExtensionFilter("TSV files (*.txt)", "*.tsv"));
chooser.setTitle("Choose annotation file");
File f = chooser.showOpenDialog(null);
if (f != null) {
String path = f.getAbsolutePath();
String header = null;
BufferedReader reader = null;
try {
reader = new BufferedReader(new FileReader(path));
header = reader.readLine();
reader.close();
} catch (FileNotFoundException e) {
PopUps.showInfoMessage("File is not found", "Error: missing file");
return;
} catch (IOException e) {
PopUps.showInfoMessage("An error occurred during importing", "Error: importing is not completed");
}
// handles my old annotation
if (header != null && header.equals(LoincEntry.getHeaderLine())) {
FromFile parser = new FromFile(path, model.getOntology());
Set<UniversalLoinc2HPOAnnotation> testset = parser.getTests();
for (UniversalLoinc2HPOAnnotation test : testset) {
model.addLoincTest(test);
}
}
// handles my current TSV annotation
if (header != null && header.equals(UniversalLoinc2HPOAnnotation.getHeaderAdvanced())) {
Map<LoincId, UniversalLoinc2HPOAnnotation> annotationMap = null;
try {
annotationMap = WriteToFile.fromTSV(path, model.getTermMap2());
} catch (FileNotFoundException e) {
// already handled
}
model.getLoincAnnotationMap().putAll(annotationMap);
}
}
logger.debug("Num of annotations in model: " + model.getLoincAnnotationMap().size());
refreshTable();
annotateTabController.changeColorLoincTableView();
}
use of org.monarchinitiative.loinc2hpo.io.FromFile in project loinc2hpo by monarch-initiative.
the class FhirObservationParserTest method setup.
@BeforeClass
public static void setup() throws IOException {
ClassLoader classLoader = FhirObservationParserTest.class.getClassLoader();
String obopath = classLoader.getResource("obo/hp.obo").getFile();
String loincpath = classLoader.getResource("loinc2hpoAnnotationTest.tsv").getFile();
HPOParser parser = new HPOParser(obopath);
HpoOntology ontology = parser.getHPO();
loincparser = new FromFile(loincpath, ontology);
testmap = loincparser.getTestmap();
String fhirPath = classLoader.getResource("json/glucoseHigh.fhir").getFile();
ObjectMapper mapper = new ObjectMapper();
File f = new File(fhirPath);
FileInputStream fis = new FileInputStream(f);
byte[] data = new byte[(int) f.length()];
fis.read(data);
fis.close();
node = mapper.readTree(data);
}
Aggregations