Skip to content

Instantly share code, notes, and snippets.

@sacdallago
Last active March 19, 2019 07:33
Show Gist options
  • Save sacdallago/372ba0659c03a93b1f5033a88040f6c7 to your computer and use it in GitHub Desktop.
Save sacdallago/372ba0659c03a93b1f5033a88040f6c7 to your computer and use it in GitHub Desktop.
Hippie entry name to uniprot ID

Prerequisites:

Node.js has to be installed. Also parsjs (get it via npm i -g parsjs).

Steps:

  1. Download latest hippie release (the TAB version)
  2. Run parsjs -n -s hippie_current hippie_current.txt
  3. Run node unique.js
  4. Copy the content of current_hippie_identifiers.txt on the uniprot mapping service (https://www.uniprot.org/mapping/)
  5. From the columns, deselect everything except 'entry' and 'entry name'
  6. Download in TSV format, call file 'DOWNLOADED.tab' and place in directory with the scripts
  7. Run parsjs -s mapping DOWNLOADED.tab
  8. Run node convert.js

You should now have hippie_current_uniprotID.json and hippie_unidentifiable.txt, the latter tells you which IDs couldn't be mapped.

const mapping = require('./mapping.json');
const hippie = require('./hippie_current.json');
const fs = require('fs');
let unidentifiable = [];
let map = {};
mapping.forEach(e => map[e['entry name']] = e['entry']);
let result = hippie.map(e => {
let r = {...e};
let match1 = map[e['val0']];
if(match1 === undefined){
unidentifiable.push(e['val0']);
r['val0'] = undefined;
} else {
r['val0'] = match1;
}
let match2 = map[e['val2']];
if(match2 === undefined){
unidentifiable.push(e['val2']);
r['val2'] = undefined;
} else {
r['val2'] = match2;
}
return r;
});
let uniqueUnidentifiable = new Set(unidentifiable);
let noNullResults = result.filter(e => e['val0'] !== undefined && e['val2'] !== undefined);
fs.writeFile("hippie_current_uniprotID.json", JSON.stringify(noNullResults), function(err) {
if (err) {
console.log(err);
}
});
fs.writeFile("hippie_unidentifiable.txt", [...uniqueUnidentifiable].join("\n"), function(err) {
if (err) {
console.log(err);
}
});
const fs = require('fs');
const hippie = require('./hippie_current.json');
let val0 = hippie.map(e => e['val0']);
let val2 = hippie.map(e => e['val2']);
let unique = new Set([... val0,... val2]);
fs.writeFile("current_hippie_identifiers.txt", [... unique].join("\n"), function(err) {
if (err) {
console.log(err);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment