Skip to content

Commit

Permalink
Updates the data by default daily
Browse files Browse the repository at this point in the history
  • Loading branch information
scourgemancer authored and nicholastmosher committed Feb 19, 2020
1 parent ed6cdbb commit 64f3a4b
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ services:
environment:
GENES_FILE: "/ifad/files/gene-types.txt"
ANNOTATIONS_FILE: "/ifad/files/tair.gaf"
UPDATE_INTERVAL: 86400000
ports:
- 80:3000
volumes:
Expand Down
38 changes: 38 additions & 0 deletions src/utils/ingest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -462,3 +462,41 @@ export const ingestData = (raw: UnstructuredText): StructuredData | null => {
// Return all structured data
return {genes, annotations, raw};
};

const { geneMap, annotations, groupedAnnotations } = readData();
let mostRecentGeneMap = geneMap;
let mostRecentAnnotations = annotations;
let mostRecentGroupedAnnotations = groupedAnnotations;

const updateData = () => {
const { execSync } = require("child_process");
const stdout = execSync("wget http://current.geneontology.org/annotations/tair.gaf.gz ; gunzip tair.gaf.gz");

const { geneMap, annotations, groupedAnnotations } = readData();
mostRecentGeneMap = geneMap;
mostRecentAnnotations = annotations;
mostRecentGroupedAnnotations = groupedAnnotations;
};

let nextDate = new Date();
if (nextDate.getMinutes() === 0 && nextDate.getSeconds() === 0) {
let interval = process.env["UPDATE_INTERVAL"];
if (interval) {
const runningInterval = setInterval(updateData, parseInt(interval));
} else {
const runningInterval = setInterval(updateData, (1000 * 60 * 60 * 24));
}
} else {
nextDate.setDate(nextDate.getDate() + 1);
nextDate.setHours(0);
nextDate.setMinutes(0);
nextDate.setSeconds(0);
let difference = nextDate.getTime() - new Date().getTime();
setTimeout(updateData, difference);
}

export const getGeneMap = (): GeneMap => { return mostRecentGeneMap; };

export const getAnnotations = (): IAnnotation[] => { return mostRecentAnnotations; };

export const getGroupedAnnotations = (): GroupedAnnotations<Set<IGene>> => { return mostRecentGroupedAnnotations; };

0 comments on commit 64f3a4b

Please sign in to comment.