/* eslint no-console: 0 */

const args = require('./args');
const domains = require('./domains/domains');
const geneNames = require('./gene-names/gene-names');
const generateDB = require('./generate-db');
const getProteinExpressionData = require('./expression/protein/get-data');
const getRNAExpressionData = require('./expression/rna/get-data');
const getGoHierarchy = require('./go/go');
const interactions = require('./interactions/interactions');
const localization = require('./localization/localization');
const regions = require('./regions/regions');

const uniprot = require('./uniprot/uniprot');
const writeTissues = require('./write-tissues');

const options = args();

/* Retrieve and perform initial processing of database files, including
** unzip and splitting to species files as needed. DB files are split to
** individual species files as they are generally too large to read into
** memory otherwise. Pfam retrieval and processing is done after Uniprot
** as splitting domains to individual files requires a list of Uniprot IDs to
** keep. */

const main = async () => {
  try {
    console.log('Fetching gene data (1/9)');
    await geneNames(options);
    console.log('Fetching GO files (2/9)');
    await getGoHierarchy(options);
    console.log('Fetching protein expression data (3/9)');
    await getProteinExpressionData(options);
    console.log('Fetching RNA expression data (4/9)');
    await getRNAExpressionData(options);
    console.log('Fetching interactions (5/9)');
    await interactions(options);
    console.log('Fetching localizations (6/9)');
    await localization(options);
    console.log('Fetching UniProt database (7/9)');
    await uniprot(options);

    console.log('Fetching Pfam data (8/9)');
    await Promise.all([
      domains(options),
      regions(options),
    ]);

    console.log('Generating database (9/9)');
    const { protein, rna } = await generateDB();
    await writeTissues(rna, './files/rna-tissues.js');
    await writeTissues(protein, './files/protein-tissues.js');
  } catch (err) {
    console.error(err);
  }
};

main();

@@ -1129,17 +1129,18 @@
 data (1/
-9
+10
 )');%0A   
@@ -1204,17 +1204,18 @@
 iles (2/
-9
+10
 )');%0A   
@@ -1299,17 +1299,18 @@
 data (3/
-9
+10
 )');%0A   
@@ -1400,17 +1400,18 @@
 data (4/
-9
+10
 )');%0A   
@@ -1490,17 +1490,18 @@
 ions (5/
-9
+10
 )');%0A   
@@ -1573,17 +1573,18 @@
 ions (6/
-9
+10
 )');%0A   
@@ -1659,17 +1659,18 @@
 base (7/
-9
+10
 )');%0A   
@@ -1694,17 +1694,16 @@
 tions);%0A
-%0A
     cons
@@ -1730,16 +1730,20 @@
 am d
-ata
+omains
  (8/
-9
+10
 )');
@@ -1757,51 +1757,84 @@
 ait 
-Promise.all(%5B%0A      domains(options),%0A     
+domains(options);%0A    console.log('Fetching Pfam regions (9/10)');%0A    await
  reg
@@ -1850,16 +1850,8 @@
 ons)
-,%0A    %5D)
 ;%0A%0A 
@@ -1891,11 +1891,13 @@
 se (
-9/9
+10/10
 )');

Refactor database generation steps