| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- import {getInteractionsFromEntry, readOffset} from '.'
- import fs from 'fs'
- import readline from 'readline'
- const { Database, aql } = require("arangojs");
- import { XMLParser } from 'fast-xml-parser'
- const db = new Database({
- url: "http://localhost:8529",
- databaseName: "test",
- auth: { username: "root", password: "test123" },
- });
- const line$ = (path: string) => readline.createInterface({
- input: fs.createReadStream(path),
- crlfDelay: Infinity
- })
- const parser = new XMLParser({
- ignoreAttributes: false,
- alwaysCreateTextNode: false,
- attributeNamePrefix: "",
- textNodeName: "value",
- allowBooleanAttributes: true,
- })
- ;(async()=>{
- const uniprotDB = '/home/thomas/NGS/ref/UNIPROT/uniprot_sprot_human.xml'
- for await (const line of line$(uniprotDB + '.jsi')) {
- const acc = /;/.test(line) ? line.split(';')[0] : line.split(/\t/)[0]
- const [from, to] = [line.split(/\t/)[1], line.split(/\t/)[2]]
- const tmp = parser.parse(await readOffset(uniprotDB, Number(from), Number(to)))
- if(Object.keys(tmp).length === 0) {
- break
- } else {
- try {
- const inter = await getInteractionsFromEntry(tmp)
- } catch (error) {
- console.log(error)
- console.log(acc)
- console.log(tmp.entry.gene)
- console.log(tmp)
- break
- }
- }
- }
- })()
|