List of usage examples for java.io Reader toString
public String toString()
From source file:org.intermine.bio.dataconversion.XenmineConverter.java
/** * //from ww w. j a v a2 s . c om * @param reader * @throws Exception * @throws ObjectStoreException */ private void processGenePageFile(Reader preader) throws Exception, ObjectStoreException { /* XB-GENEPAGE ID * XB-GENE IDs for tropicalis and laevis * The XB-GENE IDs are comma-separated * It seems like first one is tropicals, rest are laevis (a & b) */ System.out.println("Processing Gene Page file...."); Iterator<?> tsvIter; try { tsvIter = FormattedTextParser.parseTabDelimitedReader(preader); } catch (Exception e) { throw new Exception("cannot parse file: " + preader.toString(), e); } while (tsvIter.hasNext()) { String[] line = (String[]) tsvIter.next(); if (line.length < 2) { LOG.error("Couldn't process line. Expected 2 cols, but was " + line.length); continue; } String genePageName = line[0].trim().substring(12); String geneIds = line[1].trim(); if (geneIds.indexOf(",") != -1) { String[] refs = geneIds.split(","); for (int i = 0; i < refs.length; i++) { addGenePageId(refs[i], genePageName); } } else { addGenePageId(geneIds, genePageName); } } preader.close(); //print out contents for (Map.Entry<String, HashSet> entry : genesPageName.entrySet()) { System.out.printf("Key : %s and Value: %s %n", entry.getKey(), entry.getValue()); } }
From source file:org.intermine.bio.dataconversion.XenmineConverter.java
/** * // w w w. j a v a2s . c om * @param reader * @throws Exception * @throws ObjectStoreException */ private void processSynFile(Reader preader) throws Exception, ObjectStoreException { /* Xenbase gene ID * gene symbol * gene name * gene function -- will store as description * gene synonyms * JGI ID -- missing from the file --not required */ System.out.println("Processing Synonym file...."); Iterator<?> tsvIter; try { tsvIter = FormattedTextParser.parseTabDelimitedReader(preader); } catch (Exception e) { throw new Exception("cannot parse file: " + preader.toString(), e); } while (tsvIter.hasNext()) { String[] line = (String[]) tsvIter.next(); if (line.length < 5) { LOG.error("Couldn't process line. Expected 5 cols, but was " + line.length); continue; } String genePageId = line[0].trim().substring(12); String symbol = line[1].trim(); String name = line[2].trim(); String desc = line[3].trim(); String synonyms = line[4].trim(); HashSet geneIds = genesPageName.get(genePageId); Iterator it = geneIds.iterator(); while (it.hasNext()) { String geneId = (String) it.next(); Item gene = genes.get(geneId); if (gene != null) { if (desc != null && !StringUtils.isEmpty(desc)) { gene.setAttribute("briefDescription", desc); } if (synonyms != null && !StringUtils.isEmpty(synonyms)) { gene.setAttribute("alias", synonyms); if (synonyms.indexOf("|") != -1) { String[] syns = synonyms.split("\\|"); for (int i = 0; i < syns.length; i++) { getSynonym(gene.getIdentifier(), syns[i]); } } else { getSynonym(gene.getIdentifier(), synonyms); } } } else { System.out .println("gene page id for a gene that is not laoded in the prev file.." + genePageId); } } } preader.close(); }
From source file:org.intermine.bio.dataconversion.ZfinExpressionConverterTest.java
public void testProcess() throws Exception { Reader reader = new InputStreamReader(getClass().getClassLoader().getResourceAsStream("2xpatres.txt")); System.out.println("***" + reader.toString()); converter.process(reader);/*from www . j a va2s . c om*/ converter.close(); // uncomment to write out a new target items file writeItemsFile(itemWriter.getItems(), "ZfinExpression-tgt-items.xml"); Set expected = readItemSet("ZfinExpression-tgt-items.xml"); assertEquals(expected, itemWriter.getItems()); }