<commit_before>#!/usr/bin/env node
var geneToOsReaction = {};
var geneToProjReaction = {};
require('readline').createInterface({
  input: require('fs').createReadStream(process.argv[2]),
  terminal: false
})
.on('line', function(line) {
  var fields = line.split("\t");
  if (fields.length === 8) {
    var Os_gene_id = fields[4];
    var Proj_gene_id = fields[6];
    var Os_reaction_id = fields[1];
    var Proj_reaction_id = fields[2];
    // rice gene to rice reaction
    if (!geneToOsReaction.hasOwnProperty(Os_gene_id)) {
      geneToOsReaction[Os_gene_id] = {};
    }
    geneToOsReaction[Os_gene_id][Os_reaction_id] = 1;
    // projected gene to rice reaction
    if (!geneToOsReaction.hasOwnProperty(Proj_gene_id)) {
      geneToOsReaction[Proj_gene_id] = {};
    }
    geneToOsReaction[Proj_gene_id][Os_reaction_id] = 1;
    // projected gene to projected reaction
    if (!geneToProjReaction.hasOwnProperty(Proj_gene_id)) {
      geneToProjReaction[Proj_gene_id] = {};
    }
    geneToProjReaction[Proj_gene_id][Proj_reaction_id] = 1;
    // rice gene to rice reaction, but in the geneToProjReaction hash
    if (!geneToProjReaction.hasOwnProperty(Os_gene_id)) {
      geneToProjReaction[Os_gene_id] = {};
    }
    geneToProjReaction[Os_gene_id][Os_reaction_id] = 1;
  }
})
.on('close', function() {
  // read genes documents
  require('readline').createInterface(
    {
      input: process.stdin,
      terminal: false
    }
  )
  .on('line', function(line) { // one JSON object per line
     var gene = JSON.parse(line);
     if (geneToOsReaction.hasOwnProperty(gene._id)) {
       gene.xrefs.pathways = Object.keys(geneToOsReaction[gene._id]); // these become pathways__ancestors in add_xref_ancestors.js
       gene.xrefs.reactions = Object.keys(geneToProjReaction[gene._id]); // these are for linking to plant reactome
     }
     console.log(JSON.stringify(gene));
  });
});<commit_msg>use toUpperCase() on ids to make sure they match<commit_after>#!/usr/bin/env node
var geneToOsReaction = {};
var geneToProjReaction = {};
require('readline').createInterface({
  input: require('fs').createReadStream(process.argv[2]),
  terminal: false
})
.on('line', function(line) {
/*
0  Os Reaction Name
1  Os Reaction DB ID
2  Proj Reaction DB ID
3  Proj Reaction Species
4  Os Gene Product Locus ID
5  Os Gene Product DB ID
6  Proj Gene Product Locus ID
7  Proj Gene Product DB ID
*/
  var fields = line.split("\t");
  if (fields.length === 8) {
    var Os_gene_id = fields[4].toUpperCase();
    var Proj_gene_id = fields[6].toUpperCase();
    var Os_reaction_id = fields[1];
    var Proj_reaction_id = fields[2];
    // rice gene to rice reaction
    if (!geneToOsReaction.hasOwnProperty(Os_gene_id)) {
      geneToOsReaction[Os_gene_id] = {};
    }
    geneToOsReaction[Os_gene_id][Os_reaction_id] = 1;
    // projected gene to rice reaction
    if (!geneToOsReaction.hasOwnProperty(Proj_gene_id)) {
      geneToOsReaction[Proj_gene_id] = {};
    }
    geneToOsReaction[Proj_gene_id][Os_reaction_id] = 1;
    // projected gene to projected reaction
    if (!geneToProjReaction.hasOwnProperty(Proj_gene_id)) {
      geneToProjReaction[Proj_gene_id] = {};
    }
    geneToProjReaction[Proj_gene_id][Proj_reaction_id] = 1;
    // rice gene to rice reaction, but in the geneToProjReaction hash
    if (!geneToProjReaction.hasOwnProperty(Os_gene_id)) {
      geneToProjReaction[Os_gene_id] = {};
    }
    geneToProjReaction[Os_gene_id][Os_reaction_id] = 1;
  }
})
.on('close', function() {
  // read genes documents
  require('readline').createInterface(
    {
      input: process.stdin,
      terminal: false
    }
  )
  .on('line', function(line) { // one JSON object per line
     var gene = JSON.parse(line);
     if (geneToOsReaction.hasOwnProperty(gene._id.toUpperCase())) {
       gene.xrefs.pathways = Object.keys(geneToOsReaction[gene._id.toUpperCase()]); // these become pathways__ancestors in add_xref_ancestors.js
       gene.xrefs.reactions = Object.keys(geneToProjReaction[gene._id.toUpperCase()]); // these are for linking to plant reactome
     }
     console.log(JSON.stringify(gene));
  });
});
{'fraction_non_alphanumeric': 0.12785055798156233, 'fraction_numerical': 0.006792819019893256, 'mean_word_length': 3.8053613053613056, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3270196', 'n_tokens_mistral': 1503, 'n_tokens_neox': 1425, 'n_words': 280}