Skip to content

Commit 27adfc0

Browse files
author
jynlix
committed
support snpedia
1 parent 4d4075f commit 27adfc0

File tree

10 files changed

+503
-7
lines changed

10 files changed

+503
-7
lines changed

config.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ const config = {
22
srcdb:{
33
'HGNC': 'http://rest.genenames.org/fetch/status/Approved',
44
'entrez': 'https://eutils.ncbi.nlm.nih.gov/entrez/eutils/esummary.fcgi?db=gene&retmode=json&id=',
5-
'ensembl': 'https://rest.ensembl.org/lookup/symbol/homo_sapiens/'
5+
'ensembl': 'https://rest.ensembl.org/lookup/symbol/homo_sapiens/',
6+
'snpedia': 'https://bots.snpedia.com/api.php'
67
},
78
targetdb: {
89
host: 'localhost',

db/initdb.sql

+18-1
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,22 @@ create table genes (
1616
location varchar(10) not null,
1717
region_start int not null,
1818
region_end int not null,
19-
band varchar(32) not null
19+
band varchar(50) not null
20+
);
21+
22+
create table snp (
23+
id serial primary key,
24+
rsid int not null,
25+
description text,
26+
genes_id int
27+
);
28+
29+
create table genotypes (
30+
id serial primary key,
31+
pair varchar(10),
32+
orientation varchar(10),
33+
magnitude int,
34+
repute varchar(10),
35+
summary text,
36+
snp_id int
2037
);

doc/schema.pdf

124 Bytes
Binary file not shown.

genedb.js

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
const commander = require('commander');
2+
const {createSnps, createGenotypes, translateSnps, translateGenotypes} = require('./snpedia');
3+
4+
commander
5+
.version('1.0.0')
6+
.description('Create different genetic databases locally.');
7+
8+
commander
9+
.command('createsnps')
10+
.description('Create snps from snpedia if not exist.')
11+
.action(()=>{
12+
createSnps();
13+
});
14+
15+
commander
16+
.command('creategenotypes')
17+
.description('Create all genotypes of a snp')
18+
.action(()=>{
19+
createGenotypes();
20+
});
21+
22+
commander
23+
.command('translatesnps')
24+
.description('Translate snps into Chinese')
25+
.action(()=>{
26+
translateSnps();
27+
});
28+
29+
commander
30+
.command('translategenotypes')
31+
.description('Translate genotypes into Chinese')
32+
.action(()=>{
33+
translateGenotypes();
34+
});
35+
36+
commander.parse(process.argv);

model/genes.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,13 @@ var genes = seq.define('genes', {
2929
type: Sequelize.INTEGER,
3030
},
3131
band:{
32-
type: Sequelize.STRING(32)
32+
type: Sequelize.STRING(50)
3333
}
3434
},
3535
{
3636
underscored: true,
3737
freezeTableName: true // Model tableName will be the same as the model name
3838
});
3939

40-
genes.belongsTo(chromosome);
40+
//genes.belongsTo(chromosome);
4141
module.exports=genes;

model/genotypes.js

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
var seq = require('./seq.js');
2+
var Sequelize = require('sequelize');
3+
var snps = require('./snp.js');
4+
var genotypes = seq.define('genotypes', {
5+
id: {
6+
type: Sequelize.INTEGER,
7+
autoIncrement: true,
8+
primaryKey: true
9+
},
10+
pair: {
11+
type: Sequelize.TEXT,
12+
},
13+
magnitude:{
14+
type: Sequelize.FLOAT,
15+
},
16+
repute:{
17+
type: Sequelize.STRING(10),
18+
},
19+
summary:{
20+
type:Sequelize.TEXT,
21+
},
22+
snp_id: {
23+
type: Sequelize.INTEGER,
24+
},
25+
name: {
26+
type: Sequelize.STRING(50),
27+
}
28+
},
29+
{
30+
underscored: true,
31+
freezeTableName: true // Model tableName will be the same as the model name
32+
});
33+
34+
genotypes.belongsTo(snps);
35+
module.exports=genotypes;

model/seq.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,11 @@ var sequelize = new seq(
1111
timestamps: false //为模型添加 createdAt 和 updatedAt 两个时间戳字段(true or false)
1212
},
1313
pool: { //使用连接池连接,默认为true
14-
max: 50,
14+
max: 80,
1515
min: 0,
16-
idle: 30000
16+
idle: 1000,
17+
evict: 1000,
18+
acquire: 200000
1719
},
1820
});
1921

model/snp.js

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
var seq = require('./seq.js');
2+
var Sequelize = require('sequelize');
3+
var gene = require('./genes.js');
4+
var snps = seq.define('snp', {
5+
id: {
6+
type: Sequelize.INTEGER,
7+
autoIncrement: true,
8+
primaryKey: true
9+
},
10+
description:{
11+
type: Sequelize.TEXT,
12+
},
13+
rsid: {
14+
type: Sequelize.STRING(50),
15+
},
16+
alias: {
17+
type: Sequelize.STRING(50),
18+
},
19+
genes_id: {
20+
type: Sequelize.INTEGER,
21+
},
22+
position:{
23+
type: Sequelize.INTEGER
24+
},
25+
orientation:{
26+
type: Sequelize.STRING(10)
27+
}
28+
},
29+
{
30+
underscored: true,
31+
freezeTableName: true // Model tableName will be the same as the model name
32+
});
33+
34+
snps.belongsTo(gene,{foreignKey:'genes_id'});
35+
module.exports=snps;

package.json

+8-1
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,15 @@
2323
},
2424
"homepage": "https://github.com/genostack/genedb#readme",
2525
"dependencies": {
26+
"commander": "^2.18.0",
27+
"google-translate-api": "^2.3.0",
2628
"google-translate-api-cn": "^1.0.1",
29+
"mwbot": "^1.0.10",
2730
"node-fetch": "^2.2.0",
28-
"sequelize": "^4.38.0"
31+
"pg": "^7.4.3",
32+
"pg-hstore": "^2.3.2",
33+
"sequelize": "^4.38.0",
34+
"xmldom": "^0.1.27",
35+
"xpath": "0.0.27"
2936
}
3037
}

0 commit comments

Comments
 (0)