@Override protected void initialiseDefaultFetcher() throws BridgeFailedException { String urlString = getEnricherContext().getConfig().getOboUrl(); InputStream stream = null; File tempFile = null; try { URL url = new URL(urlString); stream = url.openStream(); tempFile = MIFileUtils.storeAsTemporaryFile( stream, "cvFetcher_" + System.currentTimeMillis(), ".obo"); super.setOboFetcher( new OboSourceFetcher(CvTermUtils.createPsiMiDatabase(), tempFile.getAbsolutePath())); } catch (MalformedURLException e) { throw new BridgeFailedException("Cannot open URL " + urlString, e); } catch (IOException e) { throw new BridgeFailedException("Cannot read URL " + urlString, e); } finally { if (stream != null) { try { stream.close(); } catch (IOException e) { e.printStackTrace(); } } if (tempFile != null) { tempFile.delete(); } } }
@Test public void test_write_interaction_type() throws XMLStreamException, IOException, IllegalRangeException { BinaryInteractionEvidence interaction = new DefaultNamedBinaryInteractionEvidence(); ParticipantEvidence participant = new DefaultNamedParticipantEvidence(InteractorUtils.createUnknownBasicInteractor()); interaction.addParticipant(participant); interaction.setInteractionType(CvTermUtils.createMICvTerm("association", "MI:0914")); elementCache.clear(); XmlNamedInteractionEvidenceWriter writer = new XmlNamedInteractionEvidenceWriter(createStreamWriter(), this.elementCache); writer.write(interaction); streamWriter.flush(); Assert.assertEquals(this.interaction_type, output.toString()); }
@Test public void test_write_interaction_attributes() throws XMLStreamException, IOException, IllegalRangeException { BinaryInteractionEvidence interaction = new DefaultNamedBinaryInteractionEvidence(); ParticipantEvidence participant = new DefaultNamedParticipantEvidence(InteractorUtils.createUnknownBasicInteractor()); interaction.addParticipant(participant); interaction.getAnnotations().add(new DefaultAnnotation(new DefaultCvTerm("test2"))); interaction.getAnnotations().add(new DefaultAnnotation(new DefaultCvTerm("test3"))); interaction.setComplexExpansion(CvTermUtils.createMICvTerm("spoke expansion", "MI:1060")); elementCache.clear(); XmlNamedBinaryInteractionEvidenceWriter writer = new XmlNamedBinaryInteractionEvidenceWriter(createStreamWriter(), this.elementCache); writer.write(interaction); streamWriter.flush(); Assert.assertEquals(this.interaction_attributes, output.toString()); }