-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgwascatalog.m
36 lines (30 loc) · 968 Bytes
/
gwascatalog.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
function [gwas] = gwascatalog(updatefile)
if nargin < 1
updatefile = false;
end
if ~updatefile
load('gwascatalog', 'gwas');
else
fullURL = 'http://www.genome.gov/admin/gwascatalog.txt';
str = urlread(fullURL);
temp = textscan(str, '%s', 'delimiter', '\n');
tags = textscan(temp{1}{1}, '%s', 'delimiter', '\t');
content = textscan(str, repmat('%s', 1, length(tags{1})), 'delimiter', '\t');
disease = {};
gene = {};
allele = {};
for i = 1:length(content{1})
tempgene = textscan(strrep(content{14}{i}, ' ', ''), '%s', 'delimiter', ',');
tempgene = tempgene{1};
disease = [disease; repmat(content{8}(i), length(tempgene), 1)];
gene = [gene; tempgene];
allele = [allele; repmat(content{21}(i), length(tempgene), 1)];
end
gwas.disease = disease;
gwas.gene = gene;
gwas.allele = allele;
olddir = pwd;
cdpge;
save('gwascatalog', 'gwas');
cd(olddir);
end