test.ts 2.1 KB

123456789101112131415161718192021222324252627282930313233
  1. import { getSymbol, makeRefSeqFromReg, getFromAcc, getOffsets, getData } from '.'
  2. import fs from 'fs'
  3. ( async () => {
  4. // wget ftp://ftp.ncbi.nlm.nih.gov/refseq/H_sapiens/RefSeqGene/LRG_RefSeqGene
  5. const LRGPath = '/home/thomas/NGS/ref/ncbi/LRG_RefSeqGene'
  6. // wget https://ftp.ncbi.nlm.nih.gov/genomes/all/annotation_releases/9606/109.20211119/GCF_000001405.39_GRCh38.p13/GCF_000001405.39_GRCh38.p13_feature_table.txt.gz
  7. const tablePath = '/home/thomas/NGS/ref/ncbi/GCF_000001405.39_GRCh38.p13_feature_table.txt'
  8. // wget ftp://ftp.ncbi.nlm.nih.gov/refseq/H_sapiens/biological_region/human.biological_region.gbff.gz
  9. const regionDBPath = '/home/thomas/NGS/ref/ncbi/REGIONS/human.biological_region.gbff'
  10. // wget ftp://ftp.ncbi.nlm.nih.gov/refseq/H_sapiens/RefSeqGene/refseqgene.[1-7].genomic.gbff.gz
  11. const geneDBPath = [1,2,3,4,5,6,7].map(n => '/home/thomas/NGS/ref/ncbi/GENES/refseqgene.' + n + '.genomic.gbff')
  12. // wget ftp://ftp.ncbi.nlm.nih.gov/refseq/H_sapiens/mRNA_Prot/human.[1-10].rna.gbff.gz
  13. const rnaDBPath = [1,2,3,4,5,6,7,8,9,10].map(n => '/home/thomas/NGS/ref/ncbi/RNA/human.' + n + '.rna.gbff')
  14. // const res = await getSymbol('NOTCH1', LRGPath, tablePath, geneDBPath, rnaDBPath)
  15. // await makeRefSeqFromReg(rnaDBPath, /NM_/, '/home/thomas/NGS/ref/ncbi/RNA/human_NM.fa')
  16. // await makeRefSeqFromReg(rnaDBPath, /NM_/, 'test/human_NM.fa', 10)
  17. // const res = await getOffsets(rnaDBPath.map(e => e + '.jsi'), /NR_/)
  18. //const res = await getData(rnaDBPath, /NM_/, 'test/test-NM.json', '{"name": features[type="gene"].name, "accession": version}')
  19. //const res = await getData(geneDBPath, /^NG_007458/, 'test/NOCTH1-gene.json')
  20. // await fs.promises.writeFile('test/NOCTH1-gene.json', JSON.stringify(res, null , 4))
  21. const txt = await fs.promises.readFile('test/NOCTH1-gene.json')
  22. const json = JSON.parse(txt.toString())
  23. console.log(json[0].features.filter((f:any) => f.type !== 'variation'));
  24. await fs.promises.writeFile('test/gene-feat.json', JSON.stringify(json[0].features.filter((f:any) => f.type !== 'variation'), null, 4))
  25. })()