public void setBinaryInteractionIterator(Reader r, boolean hasHeader) throws ClusterServiceException { if ( r != null ) { final PsimiTabReader reader = new PsimiTabReader( ); try { this.binaryInteractionIterator = reader.iterate( r ); } catch ( Exception e ) { throw new ClusterServiceException( "An error occured while read MITAB data", e ); } } }
public BinaryInteraction mapLine(String line, int lineNumber) throws Exception { try { return psimitabReader.readLine(line); } catch (Exception e) { throw new Exception("Problem converting to binary interaction line "+lineNumber+": "+line); } } }
/** * {@inheritDoc} */ public Collection<BinaryInteraction> read(Reader reader) throws IOException, PsimiTabException { BufferedReader bufferedReader = null; Collection<BinaryInteraction> interactions; try { bufferedReader = new BufferedReader(reader); interactions = read(bufferedReader); } finally { // You only need to close the outermost stream class because the close() // call is automatically trickled through all the chained classes if (bufferedReader != null) { bufferedReader.close(); } } return interactions; }
public ClusteredMitabFilter(InteractionExporter exporter, String mitab){ super(exporter, mitab); this.mitabReader = new PsimiTabReader(); }
PsimiTabReader reader = new PsimiTabReader(); log.debug("Reading " + inputFile.getAbsolutePath()); all.addAll(reader.read(inputFile));
public PsimiTabIterator(Reader psiMiTabInteractionsReader) { boolean isHeader = true; if (psiMiTabInteractionsReader == null) { throw new IllegalArgumentException("You must give a non null input stream."); } if (psiMiTabInteractionsReader instanceof BufferedReader) { this.interactionStreamReader = (BufferedReader) psiMiTabInteractionsReader; } else { this.interactionStreamReader = new BufferedReader(psiMiTabInteractionsReader); } this.mReader = new PsimiTabReader(); try { do { String firstLine = interactionStreamReader.readLine(); if(firstLine == null){ nextLine = null; isHeader = false; } else if (!firstLine.isEmpty() && !firstLine.startsWith("#")) { //This line is not a comment, we read nextLine = mReader.readLine(firstLine); lineIndex++; isHeader = false; } } while (isHeader); } catch (Exception e) { closeStreamReader(); throw new RuntimeException("Error while reading the header line.", e); } }
public Iterator<BinaryInteraction> getBinaryInteractionIterator() throws PsimiTabException, IOException { return mitabReader.iterate(getMitab()); } }
public BinaryInteraction readLine(String str) throws PsimiTabException { BinaryInteraction interaction = null; String[] line; line = MitabParserUtils.quoteAwareSplit(str, new char[]{'\t'}, false); if (line.length > 0 && line[0].startsWith("#")) { //This line is a comment, we skip the line return null; } // line[] is an array of values from the line // Avoid the problem of the size with the different formats try { interaction = MitabParserUtils.buildBinaryInteraction(line); } catch (Throwable e) { handleError("Exception parsing line :" + Arrays.toString(line), e); } return interaction; }
public IntactSolrSearchResult(SolrDocumentList results, String [] fieldNames, List<FacetField> facetFields){ super(results, fieldNames, facetFields); mitabReader = new PsimiTabReader(); }
PsimiTabReader reader = new PsimiTabReader(); Collection<BinaryInteraction> interactions = reader.read(inputStream); Tab2Xml tab2Xml = new Tab2Xml(); EntrySet entrySet;
public List<BinaryInteraction> getInteractions(String query, int firstResult, int maxNumberOfResults) throws IOException { List<BinaryInteraction> results = new ArrayList<BinaryInteraction>(Math.min(2048, maxNumberOfResults)); String url = service.getRestUrl(); PsicquicSimpleClient client = new PsicquicSimpleClient(url); InputStream is = client.getByQuery(query, PsicquicSimpleClient.MITAB25, firstResult, maxNumberOfResults); PsimiTabReader tabReader = new PsimiTabReader(); BufferedReader in = new BufferedReader(new InputStreamReader(is)); String str; while ((str = in.readLine()) != null) { BinaryInteraction interaction = null; try { interaction = tabReader.readLine(str); } catch (PsimiTabException e) { throw new IOException("Impossible to read the mitab line", e); } results.add(interaction); } in.close(); return results; } }
/** * Cluster all the binary interactions in the mitab file and save in clustered mitab file * @param mitabFile * @param clusteredMitabFile * @throws IOException * @throws ConverterException */ public void clusterAndComputeMiScoreInteraction(String mitabFile, String clusteredMitabFile) throws IOException, ConverterException { IntActClusterScore clusterScore = new IntActClusterScore(); File mitabAsFile = new File(mitabFile); Iterator<BinaryInteraction> iterator = mitabReader.iterate(new FileInputStream(mitabAsFile)); // the binary interactions to cluster List<BinaryInteraction> interactionToProcess = new ArrayList<BinaryInteraction>(); while (iterator.hasNext()){ interactionToProcess.clear(); while (interactionToProcess.size() < 200 && iterator.hasNext()){ BinaryInteraction interaction = (BinaryInteraction) iterator.next(); interactionToProcess.add(interaction); } clusterScore.setBinaryInteractionIterator(interactionToProcess.iterator()); clusterScore.runService(); } clusterScore.saveCluster(clusteredMitabFile); }
protected Collection<BinaryInteraction> read(BufferedReader reader) throws IOException, PsimiTabException { Collection<BinaryInteraction> interactions = new ArrayList<BinaryInteraction>(); String[] line; String completeLine; int lineIndex = 0; while ((completeLine = reader.readLine()) != null) { line = MitabParserUtils.quoteAwareSplit(completeLine, new char[]{'\t'}, false); if (line != null && line.length > 0 && line[0].startsWith("#")) { //This line is a comment, we skip the line lineIndex++; continue; } // line[] is an array of values from the line // Avoid the problem of the size with the different formats try { interactions.add(MitabParserUtils.buildBinaryInteraction(line)); } catch (Throwable e) { handleError("Exception parsing line " + lineIndex + ": " + Arrays.toString(line), e); } lineIndex++; } return interactions; }
public void setBinaryInteractionIterator(InputStream inputStream, boolean hasHeader) throws ClusterServiceException { if ( inputStream != null ) { final PsimiTabReader reader = new PsimiTabReader( ); try { this.binaryInteractionIterator = reader.iterate( inputStream ); } catch ( Exception e ) { throw new ClusterServiceException( "An error occured while read MITAB data", e ); } } }
public NonClusteredMitabFilter(InteractionExporter exporter, String mitab){ super(exporter, mitab); this.mitabReader = new PsimiTabReader(); }
PsimiTabReader reader = new PsimiTabReader(); log.debug("Reading " + inputFile.getAbsolutePath()); all.addAll(reader.read(inputFile));
/** * Creates a BinaryInteraction from a lucene document * * @param doc the Document to use * @return the binary interaction * @throws psidev.psi.mi.tab.converter.txt2tab.MitabLineException * thrown if there are syntax or other problems parsing the document/line */ public T createData( Document doc ) throws PsimiTabException { String line = createPsimiTabLine( doc ); return ( T ) this.mitabReader.readLine(line); }
Iterator<BinaryInteraction> iterator = mitabReader.iterate(new FileInputStream(mitabAsFile));
/** * {@inheritDoc} */ public Collection<BinaryInteraction> read(InputStream is) throws IOException, PsimiTabException { BufferedReader bufferedReader = null; Collection<BinaryInteraction> interactions; try { bufferedReader = new BufferedReader(new InputStreamReader(is)); interactions = read(bufferedReader); } finally { // You only need to close the outermost stream class because the close() // call is automatically trickled through all the chained classes if (bufferedReader != null) { bufferedReader.close(); } } return interactions; }
public AbstractInteractionCluster( Reader r, boolean hasHeader ) throws ClusterServiceException { if ( r == null ) { throw new IllegalArgumentException( "You must give a non null MITAB Reader" ); } String [] dbNames; if (mappingIdDbNames.contains(",")){ dbNames = mappingIdDbNames.split(","); } else { dbNames = new String [] {mappingIdDbNames}; } this.binary2Encore = new Binary2Encore(dbNames); final PsimiTabReader reader = new PsimiTabReader( ); try { this.binaryInteractionIterator = reader.iterate( r ); } catch ( Exception e ) { throw new ClusterServiceException( "An error occured while read MITAB data", e ); } }