-
Notifications
You must be signed in to change notification settings - Fork 4
/
Makefile
executable file
·179 lines (146 loc) · 6.27 KB
/
Makefile
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
#################
# Interactome3d
#################
#Organism
ORGANISM = human
#Main directories
SRCDIR = $(CURDIR)/src
DATADIR = $(CURDIR)/data
ORGFILE = $(CURDIR)/organisms.tab
RESULTSDIR = $(CURDIR)/results
#Tools
NACCESS ?= $(shell which naccess)
WGET ?= $(shell which wget)
SED ?= $(shell which gsed || which sed)
CURL ?= $(shell which curl)
EGREP ?= $(shell which egrep)
SORT ?= $(shell which sort)
UNIQ ?= $(shell which uniq)
TAR ?= $(shell which tar)
PERL ?= $(shell which perl)
RSCRIPT ?= $(shell which Rscript)
#Uniprot
UNIPROTFTP ?= ftp://ftp.uniprot.org/pub/databases/uniprot/current_release/knowledgebase/reference_proteomes/
UNIPROTFASTA = $(DATADIR)/uniprot_$(ORGANISM).fasta
#Interactome3d
INT3URL ?= 'http://interactome3d.irbbarcelona.org/user_data/$(ORGANISM)/download/representative'
FILELISTPAGE ?= 'http://interactome3d.irbbarcelona.org/downloadset.php?queryid=$(ORGANISM)&release=current&path=representative'
# Necessary for variables parsing
NACCESSCUT = $(shell echo $1 | sed -r 's/([^\.]+).*/\1/')
PARENTPDB = $(shell echo $1 | sed -r 's/(.+)_[AB].pdb/\1/')
CSVCUT = $(shell sed "1d" $(ORGFILE) | grep -E '^$(1)\s' | cut -f$(2))
#List of tgz to download
FILELIST ?= $(DATADIR)/filelist.txt
#Interactions
INTERACTOME3DINTSDIR ?= $(DATADIR)/interactions
INTERACTOME3DINTSTARDIR ?= $(INTERACTOME3DINTSDIR)/tars
INTERACTOME3DINTSPDBDIR ?= $(INTERACTOME3DINTSDIR)/pdbs
INTERACTOME3DINTSRSADIR ?= $(INTERACTOME3DINTSDIR)/rsas
INTERACTOME3DINTSLOGDIR ?= $(INTERACTOME3DINTSDIR)/logs
INTERACTOME3DINTSASADIR ?= $(INTERACTOME3DINTSDIR)/asas
INTERACTOME3DINTFILE ?= $(DATADIR)/interactions.dat
#Proteins
INTERACTOME3DPROTFILE ?= $(DATADIR)/proteins.dat
INTERACTOME3DPROTSDIR ?= $(DATADIR)/proteins
INTERACTOME3DPROTSPDBDIR ?= $(INTERACTOME3DPROTSDIR)/pdbs
INTERACTOME3DPROTSRSADIR ?= $(INTERACTOME3DPROTSDIR)/rsas
INTERACTOME3DPROTSLOGDIR ?= $(INTERACTOME3DPROTSDIR)/logs
INTERACTOME3DPROTSASADIR ?= $(INTERACTOME3DPROTSDIR)/asas
#Output
INTERFACESFILE ?= $(RESULTSDIR)/interfaces.tab
INTERFACESFILE_NOTREMAPPED ?= $(RESULTSDIR)/interfaces_notmapped.tab
INTERACTPROTACC ?= $(RESULTSDIR)/accessibilities.tab
#pdb mappings
PDBPOSMAPPINGS ?= $(DATADIR)/pdb_mappings.rds
#Interactome3d
INTERACTOME3DINTSTARFILES = $(foreach FILE,$(shell grep interactions $(FILELIST) | grep tgz),$(INTERACTOME3DINTSTARDIR)/$(basename $(FILE)).tgz)
INTERACTOME3DINTPDBS = $(shell grep pdb $(INTERACTOME3DINTFILE) | cut -f 22)
INTERACTOME3DINTPDBSFILENAMES = $(addprefix $(INTERACTOME3DINTSPDBDIR)/,$(INTERACTOME3DINTPDBS))
INTERACTOME3DINTRSAS = $(INTERACTOME3DINTPDBS:%.pdb=%.rsa)
INTERACTOME3DINTRSASFILENAMES = $(addprefix $(INTERACTOME3DINTSRSADIR)/,$(INTERACTOME3DINTRSAS))
INTERACTOME3DPROTPDBS = $(addsuffix _A.pdb, $(basename $(shell grep pdb $(INTERACTOME3DINTFILE) | cut -f 22))) $(addsuffix _B.pdb,$(basename $(shell grep pdb $(INTERACTOME3DINTFILE) | cut -f 22)))
INTERACTOME3DPROTRSAS = $(INTERACTOME3DPROTPDBS:%.pdb=%.rsa)
INTERACTOME3DPROTRSASFILENAMES = $(addprefix $(INTERACTOME3DPROTSRSADIR)/,$(INTERACTOME3DPROTRSAS))
.PRECIOUS: $(FILELIST) $(INTERACTOME3DINTFILE) $(INTERACTOME3DINTRSAS)
.PHONY : int3Ddirectories clean-download int3Drsas all prepare
prepare: $(UNIPROTFASTA) download-indexes
access: accessibility
all: $(INTERFACESFILE_NOTREMAPPED) $(INTERFACESFILE) $(INTERACTPROTACC)
download-tars: $(INTERACTOME3DINTSTARFILES)
download-indexes: int3Ddirectories $(FILELIST) $(INTERACTOME3DINTFILE)
test: $(UNIPROTFASTA)
int3Ddirectories:
mkdir -p $(DATADIR)
mkdir -p $(RESULTSDIR)
mkdir -p $(INTERACTOME3DPROTSDIR)
mkdir -p $(INTERACTOME3DPROTSPDBDIR)
mkdir -p $(INTERACTOME3DPROTSRSADIR)
mkdir -p $(INTERACTOME3DPROTSLOGDIR)
mkdir -p $(INTERACTOME3DPROTSASADIR)
mkdir -p $(INTERACTOME3DINTSDIR)
mkdir -p $(INTERACTOME3DINTSPDBDIR)
mkdir -p $(INTERACTOME3DINTSRSADIR)
mkdir -p $(INTERACTOME3DINTSTARDIR)
mkdir -p $(INTERACTOME3DINTSLOGDIR)
mkdir -p $(INTERACTOME3DINTSASADIR)
int3Drsas: download-tars $(INTERACTOME3DINTRSASFILENAMES) $(INTERACTOME3DPROTRSASFILENAMES)
clean:
-rm $(INTERACTOME3DINTFILE)
-rm -r $(FILELIST)
-rm -rvf $(DATADIR)/*
-rm $(INTERFACESFILE)
-rm $(INTERACTPROTACC)
#Download fasta from uniprot
$(UNIPROTFASTA):
$(WGET) -P $(DATADIR) $(UNIPROTFTP)$(call CSVCUT,$(ORGANISM),2)/$(call CSVCUT,$(ORGANISM),3).fasta.gz
gunzip $(DATADIR)/$(call CSVCUT,$(ORGANISM),3).fasta.gz
mv $(DATADIR)/$(call CSVCUT,$(ORGANISM),3).fasta $@
#Download list of files on the
$(FILELIST):
$(WGET) -O - $(FILELISTPAGE) | $(EGREP) -o 'proteins_[0-9]+\.tgz|interactions_[0-9]+\.tgz' | $(SORT) | $(UNIQ) > $@
#Download interactions.dat
$(INTERACTOME3DINTFILE):
$(WGET) $(INT3URL)/interactions.dat -O $@
# #Downloading tgz
$(INTERACTOME3DINTSTARDIR)/%.tgz:
$(WGET) $(INT3URL)/$*.tgz -O $@
$(TAR) -xzf $@ -C $(INTERACTOME3DINTSPDBDIR)
#Creating interaction rsa using naccess
$(INTERACTOME3DINTSRSADIR)/%.rsa: $(INTERACTOME3DINTSPDBDIR)/%.pdb
-$(NACCESS) $(INTERACTOME3DINTSPDBDIR)/$*.pdb
if test -f $(call NACCESSCUT,$*).rsa; then \
mv $(call NACCESSCUT,$*).rsa $(INTERACTOME3DINTSRSADIR)/$*.rsa ;\
mv $(call NACCESSCUT,$*).log $(INTERACTOME3DINTSLOGDIR)/$*.rsa ;\
mv $(call NACCESSCUT,$*).asa $(INTERACTOME3DINTSASADIR)/$*.rsa ;\
fi
#Individual proteins extracted from interactome3d complexes
$(INTERACTOME3DPROTSPDBDIR)/%.pdb:
$(PERL) $(SRCDIR)/splitInteraction.pl $(INTERACTOME3DINTSPDBDIR)/$(call PARENTPDB, $*.pdb).pdb $(INTERACTOME3DPROTSPDBDIR)
#Creating individual protein rsa using naccess
$(INTERACTOME3DPROTSRSADIR)/%.rsa: $(INTERACTOME3DPROTSPDBDIR)/%.pdb
-$(NACCESS) $(INTERACTOME3DPROTSPDBDIR)/$*.pdb
if test -f $(call NACCESSCUT,$*).rsa; then \
mv $(call NACCESSCUT,$*).rsa $(INTERACTOME3DPROTSRSADIR)/$*.rsa ;\
mv $(call NACCESSCUT,$*).log $(INTERACTOME3DPROTSLOGDIR)/$*.rsa ;\
mv $(call NACCESSCUT,$*).asa $(INTERACTOME3DPROTSASADIR)/$*.rsa ;\
fi
$(INTERFACESFILE_NOTREMAPPED):
$(PERL) $(SRCDIR)/interactionsParser.pl \
$(INTERACTOME3DINTFILE) \
$(DATADIR) > $@
$(PDBPOSMAPPINGS): $(INTERACTOME3DINTFILE)
$(RSCRIPT) $(SRCDIR)/getPdbPositions.R \
$(INTERACTOME3DINTFILE) \
$(INTERACTOME3DINTSPDBDIR) \
$(UNIPROTFASTA) \
$@
$(INTERFACESFILE): $(PDBPOSMAPPINGS)
$(RSCRIPT) $(SRCDIR)/remapPdbPositions.R \
$(INTERFACESFILE_NOTREMAPPED) \
$(PDBPOSMAPPINGS) \
$@
#this file is not remapped
$(INTERACTPROTACC): int3Drsas
$(PERL) $(SRCDIR)/intProteinsAccParser.pl \
$(INTERACTOME3DINTFILE) \
$(DATADIR) > $@