List of usage examples for java.io Reader toString
public String toString()
From source file:org.intermine.bio.dataconversion.XenmineConverter.java
/** * //from w w w . ja va2s . c o m * @param reader * @throws Exception * @throws ObjectStoreException */ private void processInteractionsFile(Reader preader) throws Exception, ObjectStoreException { /* Xenbase gene ID * gene symbol * interactant ID:interactant symbol:co-citation occurrence */ System.out.println("Processing Interactants 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 < 3) { LOG.error("Couldn't process line. Expected 3 cols, but was " + line.length); continue; } String genePageId = line[0].trim().substring(12); String symbol = line[1].trim(); String interactants = line[2].trim(); //genePageId-PMID:symbol:someNumber if (interactants == null || interactants.length() == 0 || interactants.equals("")) { continue; } String[] interactingGenes = interactants.split(","); //System.out.println("Gene Page.."+ genePageId + " Length of inG.." + interactingGenes.length); HashSet geneIds = genesPageName.get(genePageId); Iterator it = geneIds.iterator(); while (it.hasNext()) { String geneId = (String) it.next(); Item gene = genes.get(geneId); if (interactingGenes.length != 0) { for (int i = 0; i < interactingGenes.length; i++) { String gpid[] = interactingGenes[i].split("\\:"); String genePageIdInteractant = gpid[0]; //System.out.println("gene interactant.." + genePageIdInteractant); HashSet interactingGeneIds = genesPageName.get(genePageIdInteractant); if (interactingGeneIds == null) { continue; } Iterator itt = interactingGeneIds.iterator(); while (itt.hasNext()) { String interactingGeneId = (String) itt.next(); Item interactingGene = genes.get(interactingGeneId); if (gene != null && interactingGene != null) { getInteraction(gene.getIdentifier(), interactingGene.getIdentifier()); } } } } } } preader.close(); }
From source file:org.intermine.bio.dataconversion.XenmineConverter.java
/** * //from w w w .j a va2s.c o m * @param reader * @throws Exception * @throws ObjectStoreException */ private void processExpressionFile(Reader preader) throws Exception, ObjectStoreException { /* Xenbase Gene ID - XB-GENE-865139 * Symbol - nr5a2-a * Genotype - wild type * Anatomical Tissue - XAO:0000132 liver and biliary system,XAO:0000467 dorsal pancreatic bud,XAO:0001103 ventral pancreatic bud,XAO:0003266 liver primordium * Start Stage - XAO:1000049 NF stage 35 and 36 * End Stge - XAO:1000053 NF stage 41 * assay - in situ hybridization * EvidenceID - Image - XB-IMG-26168 * Expreriment ID - XB-EXP-6382 * Source - Published * Literature ID - XB-ART-39030 * Curation Status - Complete manual curation */ System.out.println("Processing Expression file...."); Iterator<?> tsvIter; try { tsvIter = FormattedTextParser.parseTabDelimitedReader(preader); } catch (Exception e) { throw new Exception("cannot parse file: " + preader.toString(), e); //getCurrentFile() } while (tsvIter.hasNext()) { String[] line = (String[]) tsvIter.next(); if (line.length < 12) { LOG.error("Couldn't process line. Expected 12 cols, but was " + line.length); continue; } String xenbaseGeneId = line[0].trim(); String symbol = line[1].trim(); String genotype = line[2].trim(); String anatomicalTissue = line[3].trim(); String startStageFull = line[4].trim(); //XAO:1000049 NF stage 35 and 36 String[] t = startStageFull.split("\\s"); String startStage = t[0]; String endStageFull = line[5].trim(); String[] te = endStageFull.split("\\s"); String endStage = te[0]; String assay = line[6].trim(); String imageId = line[7].trim(); String experimentId = line[8].trim(); String source = line[9].trim(); String literatureId = line[10].trim(); //XB-ART-ID figure out how to merge based on PMID String pmid = pmid_xbartid.get(literatureId); String refId = getPub(pmid, literatureId); String status = line[11].trim(); //figure out how to store this stuff Item expression = createItem("ExpressionResult"); if (StringUtils.isNotEmpty(genotype)) { expression.setAttribute("genotype", genotype); } if (StringUtils.isNotEmpty(assay)) { expression.setAttribute("assay", assay); } if (StringUtils.isNotEmpty(experimentId)) { expression.setAttribute("experimentId", experimentId); } if (StringUtils.isNotEmpty(source)) { expression.setAttribute("source", source); } if (StringUtils.isNotEmpty(status)) { expression.setAttribute("curationStatus", status); } Item sterm = getTerm(startStage); Item eterm = getTerm(endStage); expression.setReference("startStage", sterm.getIdentifier()); expression.setReference("endStage", eterm.getIdentifier()); expression.setReference("publication", refId); setImage(expression, URL + imageId + ".jpg"); setAnatomicalTissues(expression, anatomicalTissue, "anatomicalStages"); Item gene = genes.get(xenbaseGeneId); if (gene != null) { //XB-GENE-478125 is not in other files expression.setReference("gene", gene.getIdentifier()); store(expression); //don't store all other items created if there is no gene to associate with..? } } preader.close(); }
From source file:org.intermine.bio.dataconversion.XenmineConverter.java
/** * //from ww w . j a v a2 s . com * @param reader * @throws Exception * @throws ObjectStoreException */ private void processAnatomyMappingFile(Reader preader) throws Exception, ObjectStoreException { /* Xenbase Gene ID * gene symbol * start stage * end stage * tissues * XB-GENEPAGE-478053 trnt1 XAO:1000031 NF stage 10.5 XAO:1000009 frog * XAO:0000001 ectoderm,XAO:0003024 head,XAO:0000129 intestine,XAO:0000133 liver,XAO:0000256 oocyte, * XAO:0000258 ovary,XAO:0000157 testis,XAO:0003004 whole organism */ System.out.println("Processing Anatomy Mapping file...."); Iterator<?> tsvIter; try { tsvIter = FormattedTextParser.parseTabDelimitedReader(preader); } catch (Exception e) { throw new Exception("cannot parse file: " + preader.toString(), e); //getCurrentFile() } while (tsvIter.hasNext()) { String[] line = (String[]) tsvIter.next(); String xenbaseGeneId = line[0].trim().substring(12); String symbol = line[1].trim(); String startStageFull = line[2].trim(); //XAO:1000049 NF stage 35 and 36 String[] t = startStageFull.split("\\s"); String startStage = t[0]; String endStageFull = line[3].trim(); String[] te = endStageFull.split("\\s"); String endStage = te[0]; String anatomicalTissue = line[4].trim(); System.out.println(xenbaseGeneId); HashSet geneIds = genesPageName.get(xenbaseGeneId); //check this stuff with what is in genes..a thorough once over Iterator it = geneIds.iterator(); while (it.hasNext()) { String geneId = (String) it.next(); Item gene = genes.get(geneId); if (gene != null) { //figure out how to store this stuff Item anatomy = createItem("AnatomyMapping"); Item sterm = getTerm(startStage); Item eterm = getTerm(endStage); anatomy.setReference("startStage", sterm.getIdentifier()); anatomy.setReference("endStage", eterm.getIdentifier()); setAnatomicalTissues(anatomy, anatomicalTissue, "tissues"); anatomy.setReference("gene", gene.getIdentifier()); store(anatomy); //don't store all other items created if there is no gene to associate with..? } } } preader.close(); }
From source file:org.intermine.bio.dataconversion.XenmineConverter.java
/** * //from w w w .ja v a2s .com * @param reader * @throws Exception * @throws ObjectStoreException */ private void processLiteratureFile(Reader preader) throws Exception, ObjectStoreException { /* Xenbase Literature ID * PMID * Xenbase genePage IDs associated with the PMID above */ System.out.println("Processing Literature file...."); Iterator<?> tsvIter; try { tsvIter = FormattedTextParser.parseTabDelimitedReader(preader); } catch (Exception e) { throw new Exception("cannot parse file: " + preader.toString(), e); //getCurrentFile() } while (tsvIter.hasNext()) { String[] line = (String[]) tsvIter.next(); if (line.length < 3) { LOG.error("Couldn't process line. Expected 3 cols, but was " + line.length); continue; } String literatureId = line[0].trim().substring(7); String pmid = line[1].trim(); String litGenes = line[2].trim(); //XB-GENEPAGE-491748 elavl2,XB-GENEPAGE-481418 gdf1,XB-GENEPAGE-481799 elavl1 if (litGenes.isEmpty() || litGenes == null) { System.out.println("empty 3rd column."); continue; } String storedRefId = getPub(pmid, literatureId); String[] gids = litGenes.split(","); if (gids.length != 0) { for (int i = 0; i < gids.length; i++) { String gpid[] = gids[i].split("\\s"); String genePageId = gpid[0].substring(12); HashSet geneIds = genesPageName.get(genePageId); //check this stuff with what is in genes..a thorough once over Iterator it = geneIds.iterator(); while (it.hasNext()) { String geneId = (String) it.next(); Item gene = genes.get(geneId); if (gene != null) { gene.addToCollection("publications", storedRefId); } } } } else { String gpid[] = litGenes.split("\\s"); String genePageId = gpid[0].substring(12); HashSet geneIds = genesPageName.get(genePageId); //check this stuff with what is in genes..a thorough once over Iterator it = geneIds.iterator(); while (it.hasNext()) { String geneId = (String) it.next(); Item gene = genes.get(geneId); if (gene != null) { gene.addToCollection("publications", storedRefId); } } } } preader.close(); }
From source file:org.intermine.bio.dataconversion.XenmineConverter.java
/** * // ww w . ja v a 2s . c o m * @param reader * @throws Exception * @throws ObjectStoreException */ private void processGoFile(Reader preader) throws Exception, ObjectStoreException { /* Xenbase genepage ID * gene symbol * GO Ids (comma separated) */ System.out.println("Processing GO file...."); Iterator<?> tsvIter; try { tsvIter = FormattedTextParser.parseTabDelimitedReader(preader); } catch (Exception e) { throw new Exception("cannot parse file: " + preader.toString(), e); //getCurrentFile() } while (tsvIter.hasNext()) { String[] line = (String[]) tsvIter.next(); if (line.length < 3) { LOG.error("Couldn't process line. Expected 3 cols, but was " + line.length); continue; } String genePageId = line[0].trim().substring(12); String symbol = line[1].trim(); String goids = line[2].trim(); //GO:0005525,GO:0007264,GO:0015031 HashSet geneIds = genesPageName.get(genePageId); if (geneIds == null) { System.out.println("genePageId: null for genes.."); continue; } Iterator it = geneIds.iterator(); while (it.hasNext()) { String geneId = (String) it.next(); Item gene = genes.get(geneId); //System.out.println("genePageId: " + genePageId + " geneId " + geneId); String[] gids = goids.split(","); for (int i = 0; i < gids.length; i++) { String goTermIdentifier = gids[i]; if (gene != null) { createGoAnnotation(gene.getIdentifier(), gene, goTermIdentifier, "XenBase", "XenBase"); } } } } preader.close(); }
From source file:org.intermine.bio.dataconversion.XenmineConverter.java
/** * /* w w w.j a v a 2s .c o m*/ * @param reader * @throws Exception * @throws ObjectStoreException */ private void processEnsemblFile(Reader preader) throws Exception, ObjectStoreException { /* Xenbase gene ID * gene symbol * description * ENSXETG00000xxxx - ensembl ID */ System.out.println("Processing Ensembl file...."); Iterator<?> tsvIter; try { tsvIter = FormattedTextParser.parseTabDelimitedReader(preader); } catch (Exception e) { throw new Exception("cannot parse file: " + preader.toString(), e); //getCurrentFile() } while (tsvIter.hasNext()) { String[] line = (String[]) tsvIter.next(); if (line.length < 4) { LOG.error("Couldn't process line. Expected 4 cols, but was " + line.length); continue; } String geneId = line[0].trim(); String symbol = line[1].trim(); String name = line[2].trim(); String ensemblId = line[3].trim(); Item gene = genes.get(geneId); if (gene != null && ensemblId != null) { gene.setAttribute("ensemblIdentifier", ensemblId); } } preader.close(); }
From source file:org.intermine.bio.dataconversion.XenmineConverter.java
/** * /* w w w. j a v a 2s .c om*/ * @param reader * @throws Exception * @throws ObjectStoreException */ private void processNonEntrezOrthologFile(Reader preader) throws Exception, ObjectStoreException { /* Xenbase * OMIM * MGI * ZFIN */ System.out.println("Processing Non Entrze Orthologs.. XenbaseGeneNonEntrezOrthologMapping.txt file...."); Iterator<?> tsvIter; try { tsvIter = FormattedTextParser.parseTabDelimitedReader(preader); } catch (Exception e) { throw new Exception("cannot parse file: " + preader.toString(), e); } String prevXenopusId = ""; while (tsvIter.hasNext()) { String[] line = (String[]) tsvIter.next(); if (line.length < 4) { LOG.error("Couldn't process line. Expected 4 cols, but was " + line.length); continue; } System.out.println(line[0].trim()); String xenopusId = line[0].trim().substring(8); //it doesn;t say GENEPAGE!! String omimId = line[1].trim(); String mgiId = line[2].trim(); String zfinId = line[3].trim(); String chickenId = line[4].trim(); if (prevXenopusId == xenopusId) { HashSet geneIds = genesPageName.get(xenopusId); Iterator it = geneIds.iterator(); while (it.hasNext()) { String geneId = (String) it.next(); Item gene0 = genes.get(geneId); if (gene0 != null) { if (!StringUtils.isEmpty(zfinId)) { String gene3 = getGene(zfinId, "7955"); if (gene3 != null) processHomologues(gene0.getIdentifier(), gene3); } } } } else { HashSet geneIds = genesPageName.get(xenopusId); Iterator it = geneIds.iterator(); while (it.hasNext()) { String geneId = (String) it.next(); Item gene0 = genes.get(geneId); if (gene0 != null) { if (!StringUtils.isEmpty(omimId)) { String gene1 = getGene(omimId, "9606"); if (gene1 != null) processHomologues(gene0.getIdentifier(), gene1); } if (!StringUtils.isEmpty(mgiId)) { String gene2 = getGene(mgiId, "10090"); if (gene2 != null) processHomologues(gene0.getIdentifier(), gene2); } if (!StringUtils.isEmpty(zfinId)) { String gene3 = getGene(zfinId, "7955"); if (gene3 != null) processHomologues(gene0.getIdentifier(), gene3); } if (!StringUtils.isEmpty(chickenId)) { String gene4 = getGene(chickenId, "9031"); if (gene4 != null) processHomologues(gene0.getIdentifier(), gene4); } } } } prevXenopusId = xenopusId; } preader.close(); }
From source file:org.intermine.bio.dataconversion.XenmineConverter.java
/** * /*from w ww .java2 s. c om*/ * @param reader * @throws Exception * @throws ObjectStoreException */ private void processZebrafishOrthologFile(Reader preader) throws Exception, ObjectStoreException { /* entrez/NCBI gene ID * Xenbase GenePage * symbol * name */ System.out.println("Processing ZebraFish Ortholog 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 < 4) { LOG.error("Couldn't process line. Expected 4 cols, but was " + line.length); continue; } String humanIdentifier = line[0].trim(); String xenopusIdentifier = line[1].trim().substring(12); if (StringUtils.isEmpty(xenopusIdentifier) || StringUtils.isEmpty(humanIdentifier)) { continue; } String gene2 = getGene(humanIdentifier, "7955"); HashSet geneIds = genesPageName.get(xenopusIdentifier); Iterator it = geneIds.iterator(); while (it.hasNext()) { String geneId = (String) it.next(); Item gene1 = genes.get(geneId); if (gene1 != null && gene2 != null) { //lot of trouble..why should this check be required..does not make sense..spend time debug processHomologues(gene1.getIdentifier(), gene2); } } } preader.close(); }
From source file:org.intermine.bio.dataconversion.XenmineConverter.java
/** * /* ww w. j ava 2 s .c o m*/ * @param reader * @throws Exception * @throws ObjectStoreException */ private void processHumanOrthologFile(Reader preader) throws Exception, ObjectStoreException { /* entrez/NCBI gene ID * Xenbase GenePage * symbol * name */ System.out.println("Processing Human Ortholog 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 < 4) { LOG.error("Couldn't process line. Expected 4 cols, but was " + line.length); continue; } String humanIdentifier = line[0].trim(); String xenopusIdentifier = line[1].trim().substring(12); if (StringUtils.isEmpty(xenopusIdentifier) || StringUtils.isEmpty(humanIdentifier)) { continue; } String gene2 = getGene(humanIdentifier, "9606"); HashSet geneIds = genesPageName.get(xenopusIdentifier); Iterator it = geneIds.iterator(); while (it.hasNext()) { String geneId = (String) it.next(); Item gene1 = genes.get(geneId); if (gene1 != null && gene2 != null) { //lot of trouble..why should this check be required..does not make sense..spend time debug processHomologues(gene1.getIdentifier(), gene2); } } } preader.close(); }
From source file:org.intermine.bio.dataconversion.XenmineConverter.java
/** * /* w w w . j a v a 2 s . c o m*/ * @param reader * @throws Exception * @throws ObjectStoreException */ private void processMouseOrthologFile(Reader preader) throws Exception, ObjectStoreException { /* entrez/NCBI gene ID * Xenbase GenePage * symbol * name */ System.out.println("Processing Mouse Ortholog 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 < 4) { LOG.error("Couldn't process line. Expected 4 cols, but was " + line.length); continue; } String mouseIdentifier = line[0].trim(); String xenopusIdentifier = line[1].trim().substring(12); if (StringUtils.isEmpty(xenopusIdentifier) || StringUtils.isEmpty(mouseIdentifier)) { continue; } String gene2 = getGene(mouseIdentifier, "10090"); HashSet geneIds = genesPageName.get(xenopusIdentifier); Iterator it = geneIds.iterator(); while (it.hasNext()) { String geneId = (String) it.next(); Item gene1 = genes.get(geneId); if (gene1 != null && gene2 != null) { //lot of trouble..why should this check be required..does not make sense..spend time debug processHomologues(gene1.getIdentifier(), gene2); } } } preader.close(); }