forked from marbl/metAMOS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathINSTALL.py
1735 lines (1596 loc) · 93.5 KB
/
INSTALL.py
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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import os, sys, string, subprocess, distutils.util, site, glob, multiprocessing
def addEnvironmentVar(varName, newValue, sep = " "):
oldVal = ""
if varName in os.environ:
oldVal = os.environ[varName]
os.environ[varName] = newValue + sep + oldVal
else:
os.environ[varName] = newValue
return oldVal
def updateMakeFileForDarwin(fileName, addedCFlags, addedLDFlags, addFlagsToCompile=False):
if OSTYPE == "Darwin":
os.system("cp %s %s.orig"%(fileName, fileName))
numCF=utils.getCommandOutput("grep -c \"CFLAGS*=\" %s.orig"%(fileName), False).strip()
numCX=utils.getCommandOutput("grep -c \"CXXFLAGS*=\" %s.orig"%(fileName), False).strip()
numLD=utils.getCommandOutput("grep -c \"LDFLAGS*=\" %s.orig"%(fileName), False).strip()
numD=utils.getCommandOutput("grep -c \^DFLAGS*=\" %s.orig"%(fileName), False).strip()
addCF = False
addLD = False
if ((numCF == "" or int(numCF) == 0) and (numCX == "" or int(numCX) == 0)):
addCF = True
if ((numCF == "" or int(numCF) == 0) and (numD == "" or int(numD) == 0)):
addLD = True
os.system("cat %s.orig |awk '{if (match($0, \"^CFLAGS.*=\")) { print $0\" %s\"; } else if (match($0, \"^CXXFLAGS.*=\")) { print $0\" %s\"; } else if (match($0, \"^LDFLAGS.*=\")) { print $0\" %s\" } else if (match($0, \"^DFLAGS =\")) { print $0\" %s\"; } else { print $0; } }' >%s"%(fileName, addedCFlags, addedCFlags, addedLDFlags, addedLDFlags, fileName))
if addCF:
os.system("cp %s %s.orig"%(fileName, fileName))
os.system("cat %s.orig |awk '{if (NR == 1) { print \"CFLAGS=%s\\nCXXFLAGS=%s\\n\"$0; } else { print $0; } }' > %s"%(fileName, addedCFlags, addedCFlags, fileName))
if addLD:
os.system("cp %s %s.orig"%(fileName, fileName))
os.system("cat %s.orig |awk '{if (NR == 1) { print \"LDFLAGS=%s\\n\"$0; } else { print $0; } }' > %s"%(fileName, addedLDFlags, fileName))
if addFlagsToCompile:
os.system("cp %s %s.orig"%(fileName, fileName))
os.system("cat %s.orig |awk '{if (match($1, \"g++\")) { sub(/g\\+\\+/, \"g++ \\$(CXXFLAGS) \\$(LDFLAGS)\", $0) } print $0; }' > %s"%(fileName, fileName))
def copyPerlLib(pathToCopy, dest):
if pathToCopy != "":
pathsToCopy = pathToCopy.strip().split("\n")
for path in pathsToCopy:
pathToCopy = os.path.dirname(path)
os.system("mkdir -p %s"%(dest))
# copy one at a time in case of conflicts
for file in os.listdir("%s%s"%(pathToCopy, os.sep)):
toCopy = file
file = "%s%s%s"%(pathToCopy, os.sep, toCopy)
if os.path.exists("%s/%s"%(dest, toCopy)):
os.system("mv %s/* %s/%s/"%(file, dest, toCopy))
else:
os.system("mv %s %s/"%(file, dest))
user_home = os.environ["HOME"]
print "<<Welcome to metAMOS install>>"
#check for python version
if (sys.version_info[0] < 2) or (sys.version_info[0] == 2 and sys.version_info[1] < 6):
print "Python version is %s. metAMOS requires at least 2.6"%(sys.version)
sys.exit(1)
#add access to utils.py, for utils dir
METAMOS_ROOT = os.getcwd().strip()
INITIAL_SRC = "%s%ssrc"%(METAMOS_ROOT, os.sep)
sys.path.append(INITIAL_SRC)
import utils
import workflow
sys.path.append(utils.INITIAL_UTILS)
shellv = os.environ["SHELL"]
#add site dir
site.addsitedir(utils.INITIAL_UTILS+os.sep+"python"+os.sep+"lib"+os.sep+"python")
site.addsitedir(utils.INITIAL_UTILS+os.sep+"python"+os.sep+"lib64"+os.sep+"python")
if "PYTHONPATH" not in os.environ:
os.environ["PYTHONPATH"] = ""
os.environ["PYTHONPATH"]+=utils.INITIAL_UTILS+os.sep+"python"+os.pathsep
os.environ["PYTHONPATH"] += utils.INITIAL_UTILS+os.sep+"python"+os.sep+"lib"+os.pathsep
os.environ["PYTHONPATH"] += utils.INITIAL_UTILS+os.sep+"python"+os.sep+"lib"+os.sep+"python"+os.pathsep
os.environ["PYTHONPATH"] += utils.INITIAL_UTILS+os.sep+"python"+os.sep+"lib64"+os.pathsep
os.environ["PYTHONPATH"] += utils.INITIAL_UTILS+os.sep+"python"+os.sep+"lib64"+os.sep+"python"+os.pathsep
sys.path.append(utils.INITIAL_UTILS+os.sep+"python")
sys.path.append(utils.INITIAL_UTILS+os.sep+"python" + os.sep+"lib"+ os.sep+"python")
sys.path.append(utils.INITIAL_UTILS+os.sep+"python" + os.sep+"lib64"+ os.sep+"python")
if 'bash' in shellv or utils.cmdExists('export'):
os.system("export PYTHONPATH=%s:$PYTHONPATH"%(utils.INITIAL_UTILS+os.sep+"python"))
os.system("export PYTHONPATH=%s:$PYTHONPATH"%(utils.INITIAL_UTILS+os.sep+"python"+os.sep+"lib"+os.sep+"python"))
os.system("export PYTHONPATH=%s:$PYTHONPATH"%(utils.INITIAL_UTILS+os.sep+"python"+os.sep+"lib64"+os.sep+"python"))
elif utils.cmdExists('setenv'):
os.system("setenv PYTHONPATH %s:$PYTHONPATH"%(utils.INITIAL_UTILS+os.sep+"python"))
os.system("setenv PYTHONPATH %s:$PYTHONPATH"%(utils.INITIAL_UTILS+os.sep+"python"+os.sep+"lib"+os.sep+"python"))
os.system("setenv PYTHONPATH %s:$PYTHONPATH"%(utils.INITIAL_UTILS+os.sep+"python"+os.sep+"lib64"+os.sep+"python"))
else:
print "Cannot set PYTHONPATH variable, unknown shell %s\n"%(shellv)
if not os.path.exists("%s"%utils.INITIAL_UTILS+os.sep+"python"+os.sep+"lib"):
os.system("mkdir %s"%utils.INITIAL_UTILS+os.sep+"python"+os.sep+"lib")
if not os.path.exists("%s"%utils.INITIAL_UTILS+os.sep+"python"+os.sep+"lib64"):
os.system("mkdir %s"%utils.INITIAL_UTILS+os.sep+"python"+os.sep+"lib64")
if not os.path.exists("%s"%utils.INITIAL_UTILS+os.sep+"python"+os.sep+"lib"+os.sep+"python"):
os.system("mkdir %s"%utils.INITIAL_UTILS+os.sep+"python"+os.sep+"lib"+os.sep+"python")
if not os.path.exists("%s"%utils.INITIAL_UTILS+os.sep+"python"+os.sep+"lib64"+os.sep+"python"):
os.system("mkdir %s"%utils.INITIAL_UTILS+os.sep+"python"+os.sep+"lib64"+os.sep+"python")
ALLOW_FAST=True
HAVE_GCC42=False
HAVE_RT=False
HAVE_QUIET_HEAD=False
GCC_VERSION=0.0
try:
GCC_VERSION=float(utils.getCommandOutput("gcc --version|grep gcc|awk '{print $NF}' |awk -F \".\" '{print $1\".\"$2}'", False))
except:
try:
GCC_VERSION=float(utils.getCommandOutput("gcc --version|grep gcc|awk '{print $3}' |awk -F \".\" '{print $1\".\"$2}'", False))
except:
print "Warning: cannot determine GCC version"
OSTYPE="Linux"
OSVERSION="1"
MACHINETYPE="x86_64"
kronaTools = "KronaTools-2.2"
#identify machine type
p = subprocess.Popen("echo `uname`", shell=True, stdin=None, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
(checkStdout, checkStderr) = p.communicate()
if checkStderr != "":
print "Warning: Cannot determine OS, defaulting to %s"%(OSTYPE)
else:
OSTYPE = checkStdout.strip()
p = subprocess.Popen("echo `uname -r`", shell=True, stdin=None, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
(checkStdout, checkStderr) = p.communicate()
if checkStderr != "":
print "Warning: Cannot determine OS version, defaulting to %s"%(OSVERSION)
else:
OSVERSION = checkStdout.strip()
p = subprocess.Popen("echo `uname -m`", shell=True, stdin=None, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
(checkStdout, checkStderr) = p.communicate()
if checkStderr != "":
print "Warning: Cannot determine system type, defaulting to %s"%(MACHINETYPE)
else:
MACHINETYPE = checkStdout.strip()
addedCFlags=""
addedLDFlags=""
oldCFlags = ""
oldCPPFlags = ""
oldCXXFlags = ""
oldLDFlags = ""
if OSTYPE == "Darwin":
p = subprocess.Popen("echo `gcc --version`", shell=True, stdin=None, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
(checkStdout, checkStderr) = p.communicate()
if "Apple" not in checkStdout:
ALLOW_FAST=False
gcc42 = utils.getCommandOutput("which g++-4.2", False)
if gcc42 == "":
HAVE_GCC42=False
else:
HAVE_GCC42=True
# global vars for building
libPath=""
clib=utils.getCommandOutput("g++ -print-file-name=libgcc.a", False)
if clib != "":
libPath="%s %s"%(libPath, clib)
cpplib=utils.getCommandOutput("g++ -print-file-name=libstdc++.a", False)
if cpplib != "":
libPath="%s %s"%(libPath, cpplib)
omplib=utils.getCommandOutput("g++ -print-file-name=libgomp.a", False)
if omplib != "":
libPath="%s %s"%(libPath, omplib)
commonFlags="-mmacosx-version-min=10.6 -static-libgcc -static-libstdc++ "
oldCFlags = addEnvironmentVar("CFLAGS", " %s "%(commonFlags))
oldCPPFlags = addEnvironmentVar("CPPFLAGS", " %s "%(commonFlags))
oldCXXFlags = addEnvironmentVar("CXXFLAGS", " %s "%(commonFlags))
oldLDFlags = addEnvironmentVar("LDFLAGS", " %s "%(libPath))
addedCFlags="%s %s"%(commonFlags, libPath)
addedLDFlags="-static-libgcc -static-libstdc++ %s"%(libPath)
libPaths = [ "/usr/lib", "/usr/lib64", "/usr/local/lib/", "/usr/local/lib64/", "/opt/local/lib/", "/opt/local/lib64/"]
for libPath in libPaths:
if os.path.exists(libPath + os.sep + "librt.a") or os.path.exists(libPath + os.sep + "librt.so"):
HAVE_RT=True
break
p = utils.getCommandOutput("head --help |grep \"\\-q\" |wc -l", False)
if int(p) >= 1:
HAVE_QUIET_HEAD=True
# get list of supported workflows
enabledWorkflows = set()
packagesToInstall = set()
knownPackages = set()
workflows = workflow.getAllWorkflows("%s/Utilities/workflows"%(METAMOS_ROOT))
for flow in workflows:
knownPackages.update(workflows[flow].programList)
manual = False
fail = False
nodbs = False
availableWf = workflow.getSupportedWorkflows("%s/Utilities/workflows"%(METAMOS_ROOT), False)
for wf in availableWf:
enabledWorkflows.update(wf.getDerivedName())
packagesToInstall.update(wf.programList)
if (len(sys.argv) > 1):
# should support tool list as well added
for i in range(1, len(sys.argv)):
arg = sys.argv[i]
if arg.lower() in workflows.keys():
packagesToInstall.update(workflows[arg.lower()].programList)
enabledWorkflows.update(workflows[arg.lower()].getDerivedName())
elif arg.lower() == "full":
for flow in workflows:
packagesToInstall.update(workflows[flow].programList)
enabledWorkflows.update(workflows[flow].getDerivedName())
print "Installing all available workflows"
elif arg.lower() == "manual":
manual = True
for flow in workflows:
enabledWorkflows.update(workflows[flow].getDerivedName())
elif arg.lower() == "nodbs":
nodbs = True
elif arg.lower() in knownPackages:
packagesToInstall.add(arg.lower())
for flow in workflows:
if arg.lower() in workflows[flow].programList:
enabledWorkflows.update(workflows[flow].getDerivedName())
break
else:
if arg != "help":
print "Unknown program or workflow %s specified."%(arg)
fail = True
if fail or help in sys.argv:
print "Available workflows: %s"%(" ".join(workflows.keys()))
print "Available packages: %s"%("\n\t".join(knownPackages))
exit(1)
if manual:
packagesToInstall = set()
for workflowName in enabledWorkflows:
print "Selected to install workflowName: %s."%(workflowName.upper())
print "Will automatically install:"
for p in packagesToInstall:
print "\t%s"%(p.title())
if not os.path.exists("./Utilities/config/usage.ok") and not os.path.exists("./Utilities/config/usage.no"):
print "MetAMOS would like to record anonymous usage statistics, is this ok ? "
dl = raw_input("Enter Y/N: ")
if dl == 'y' or dl == 'Y':
os.system("echo ok > ./Utilities/config/usage.ok")
else:
os.system("echo no > ./Utilities/config/usage.no")
# first the needed python packages
# make sure we have setuptools available
if 1:
fail = 0
try:
import setuptools
except ImportError:
fail = 1
if "setuptools" in packagesToInstall:
dl = 'y'
elif fail:
print "setuptools not found, required for install, download now?"
dl = raw_input("Enter Y/N: ")
if fail and (dl == 'y' or dl == "Y"):
os.system("curl -L https://bitbucket.org/pypa/setuptools/raw/0.7.4/ez_setup.py -o ez_setup.py")
os.system("python ez_setup.py --user")
if 1:
fail = 0
try:
import psutil
except ImportError:
fail = 1
if "psutil" in packagesToInstall:
dl = 'y'
elif fail:
print "psutil not found, required for memory usage estimation, download now?"
dl = raw_input("Enter Y/N: ")
if fail and (dl == 'y' or dl == "Y"):
os.system("curl -L http://psutil.googlecode.com/files/psutil-0.6.1.tar.gz -o ./psutil.tar.gz")
os.system("tar -C ./Utilities/python -xvf psutil.tar.gz")
os.system("mv ./Utilities/python/psutil-0.6.1 ./Utilities/python/psutil")
os.chdir("./Utilities/python/psutil")
os.system("python setup.py install --home=%spython"%(utils.INITIAL_UTILS+os.sep))
os.chdir("%s"%(METAMOS_ROOT))
os.system("rm -rf psutil.tar.gz")
if 1:
fail = 0
try:
import cython
except ImportError:
fail = 1
if "cython" in packagesToInstall:
dl = 'y'
elif fail:
print "cython modules not found, necessary for c-compiling python code, download now?"
dl = raw_input("Enter Y/N: ")
if fail and (dl == 'y' or dl == "Y"):
os.system("curl -L https://github.com/cython/cython/archive/master.zip -o ./cython.zip")
os.system("unzip ./cython.zip")
os.system("mv ./cython-master ./Utilities/python/cython")
os.chdir("./Utilities/python/cython")
os.system("python setup.py install --home=%spython"%(utils.INITIAL_UTILS+os.sep))
os.chdir(METAMOS_ROOT)
os.system("rm -rf cython.zip")
if 1:
fail = 0
try:
import pysam
except ImportError:
fail = 1
if "pysam" in packagesToInstall:
dl = 'y'
elif fail:
print "pysam python modules not found, necessary for bowtie2 alignments, download now?"
dl = raw_input("Enter Y/N: ")
if fail and (dl == 'y' or dl == "Y"):
os.system("curl -L http://pysam.googlecode.com/files/pysam-0.6.tar.gz -o ./pysam.tar.gz")
os.system("tar -C ./Utilities/python -xvf pysam.tar.gz")
os.system("mv ./Utilities/python/pysam-0.6 ./Utilities/python/pysam")
doInstall = True
#for root install
#os.system("sudo python ./Utilities/python/pysam/setup.py install")
os.chdir("./Utilities/python/pysam")
if OSTYPE == "Darwin":
if utils.getFromPath("llvm-gcc-4.2", "LLVM GCC"):
os.system("export CC=llvm-gcc-4.2")
os.system("export CXX=llvm-g++-4.2")
else:
print "Warning: Cannot install pysam on your system. Please install LLVM compiler first."
doInstall=False
if doInstall:
os.system("python setup.py build_ext --inplace")
os.system("python setup.py build")
os.system("python setup.py install --home=%spython"%(utils.INITIAL_UTILS+os.sep))
os.chdir(METAMOS_ROOT)
os.system("rm -rf pysam.tar.gz")
#WARNING: matplotlib causes install issues for multiple users
fail = 0
try:
import numpy
except ImportError:
fail = 1
if "numpy" in packagesToInstall:
dl = 'y'
elif fail:
print "numpy python modules not found, necessary for html report, download now?"
dl = raw_input("Enter Y/N: ")
if fail and (dl == 'y' or dl == "Y"):
os.system("curl -L http://downloads.sourceforge.net/project/numpy/NumPy/1.7.1/numpy-1.7.1.tar.gz -o ./numpy.tar.gz")
os.system("tar -C ./Utilities/python -xvf numpy.tar.gz")
os.system("mv ./Utilities/python/numpy-1.7.1 ./Utilities/python/numpy")
os.chdir("./Utilities/python/numpy")
os.system("python setup.py install --home=%spython"%(utils.INITIAL_UTILS+os.sep))
os.chdir(METAMOS_ROOT)
os.system("rm -rf numpy.tar.gz")
if 1:
fail = 0
try:
import matplotlib
if (matplotlib.__version__ < "1.1.0"):
fail = 1
except ImportError:
fail = 1
if "matplotlib" in packagesToInstall:
dl = 'y'
elif fail:
print "Matplot lib version %s is incompatible with metAMOS. Need version 1.1.0+, download now?"%(matplotlib.__version__)
dl = raw_input("Enter Y/N: ")
if fail and (dl == 'y' or dl == "Y"):
os.system("curl -L http://downloads.sourceforge.net/project/matplotlib/matplotlib/matplotlib-1.1.0/matplotlib-1.1.0.tar.gz -o ./matplotlib.tar.gz")
os.system("tar -C ./Utilities/python -xvf matplotlib.tar.gz")
os.system("mv ./Utilities/python/matplotlib-1.1.0 ./Utilities/python/matplotlib")
os.chdir("./Utilities/python/matplotlib")
os.system("python setup.py install --home=%spython"%(utils.INITIAL_UTILS+os.sep))
os.chdir(METAMOS_ROOT)
os.system("rm -rf matplotlib.tar.gz")
# now software
if not os.path.exists("./AMOS") or 0:
if "amos" in packagesToInstall:
dl = 'y'
else:
print "AMOS binaries not found, needed for all steps, download now?"
dl = raw_input("Enter Y/N: ")
if dl == 'y' or dl == 'Y':
os.system("curl -L ftp://ftp.cbcb.umd.edu/pub/data/metamos/amos-3.2-BETA-%s-%s.binaries.tar.gz -o ./amos-binaries.tar.gz"%(OSTYPE, MACHINETYPE))
os.system("tar -xvf amos-binaries.tar.gz")
os.system("rm -rf amos-binaries.tar.gz")
# descriptive perl module
stat = utils.getCommandOutput("perl -MStatistics::Descriptive -e 0 && echo $?", True)
if stat == "":
os.system("curl -L http://search.cpan.org/CPAN/authors/id/C/CO/COLINK/Statistics-Descriptive-2.6.tar.gz -o stat.tar.gz")
os.system("tar -xvzf stat.tar.gz")
os.chdir("Statistics-Descriptive-2.6")
os.system("perl Makefile.PL PREFIX=`pwd`/build")
os.system("make install")
os.chdir("%s"%(METAMOS_ROOT))
pathToCopy = utils.getCommandOutput("find Statistics-Descriptive-2.6/build -type d -name \"Statistics\" |grep -v auto", False)
copyPerlLib(pathToCopy, "AMOS%s%s-%s%slib"%(os.sep, OSTYPE, MACHINETYPE, os.sep))
os.system("rm -rf stat.tar.gz")
os.system("rm -rf Statistics-Descriptive-2.6")
if not os.path.exists("./Utilities/cpp%s%s-%s%skraken"%(os.sep, OSTYPE, MACHINETYPE, os.sep)):
if "kraken" in packagesToInstall:
dl = 'y'
else:
print "Kraken not found, optional for Annotate step, download now?"
dl = raw_input("Enter Y/N: ")
if dl == 'y' or dl == 'Y':
archive = "kraken.tar.gz"
os.system("curl -L ftp://ftp.cbcb.umd.edu/pub/data/metamos/kraken-0.10.3-beta.tgz -o %s"%(archive))
os.system("rm -rf ./Utilities/cpp%s%s-%s%skraken"%(os.sep, OSTYPE, MACHINETYPE, os.sep))
os.system("tar -xvzf %s"%(archive))
os.system("mv kraken-0.10.3-beta ./Utilities/cpp/%s%s-%s%skraken"%(os.sep, OSTYPE, MACHINETYPE, os.sep))
os.chdir("./Utilities/cpp/%s%s-%s%skraken"%(os.sep, OSTYPE, MACHINETYPE, os.sep))
os.system("./install_kraken.sh `pwd`/bin")
os.chdir("%s"%(METAMOS_ROOT))
os.system("rm %s"%archive)
if not os.path.exists("./Utilities/DB/kraken"):
if "kraken" in packagesToInstall:
dl = 'y'
else:
print "Kraken DB not found, required for Kraken, download now?"
dl = raw_input("Enter Y/N: ")
if dl == 'y' or dl == 'Y':
settings = utils.Settings(1, 1, "", "")
settings.OSTYPE = OSTYPE
mem = utils.getAvailableMemory(settings)
if (mem < 100) and not nodbs:
print "Insufficient memory to build full Kraken database. Requires at least 100GB of memory, using mini DB"
archive = "minikraken.tgz"
os.system("curl -L ftp://ftp.cbcb.umd.edu/pub/data/metamos/%s -o %s"%(archive, archive))
os.system("tar xvzf %s"%(archive))
os.system("mv minikraken_* ./Utilities/DB/kraken")
os.system("rm %s"%(archive))
elif not nodbs:
# first we need jellyfish which is used to build DB
# kraken needs jellyfish, if we don't find it build it and add to path
jellyfish = utils.getFromPath("jellyfish", "Jellyfish", False)
if jellyfish == "":
archive = "jellyfish.tar.gz"
os.system("curl -L http://www.cbcb.umd.edu/software/jellyfish/jellyfish-1.1.11.tar.gz -o %s"%(archive))
os.system("tar xvzf %s"%(archive))
os.system("mv jellyfish-1.1.11 ./Utilities/cpp%s%s-%s%s/jellyfish"%(os.sep, OSTYPE, MACHINETYPE, os.sep))
os.chdir("./Utilities/cpp%s%s-%s%s/jellyfish"%(os.sep, OSTYPE, MACHINETYPE, os.sep))
os.system("./configure --prefix=`pwd`")
os.system("make")
os.system("make install")
os.chdir("%s"%(METAMOS_ROOT))
pathUpdate = "%s/Utilities/cpp%s%s-%s%sjellyfish/bin/"%(METAMOS_ROOT, os.sep, OSTYPE, MACHINETYPE, os.sep)
if "PATH" in os.environ:
pathUpdate = "%s%s%s"%(os.environ["PATH"], os.pathsep, pathUpdate)
os.environ["PATH"]=pathUpdate
os.chdir("./Utilities/cpp/%s%s-%s%skraken"%(os.sep, OSTYPE, MACHINETYPE, os.sep))
os.system("./bin/kraken-build --standard --threads %d --db %s/Utilities/DB/kraken"%(multiprocessing.cpu_count() - 1, METAMOS_ROOT))
os.chdir("%s"%(METAMOS_ROOT))
if not os.path.exists("./LAP"):
if "lap" in packagesToInstall:
dl = 'y'
else:
print "LAP tool not found, needed for multiple assembly pipeline, download now?"
dl = raw_input("Enter Y/N: ")
if dl == 'y' or dl == 'Y':
os.system("curl -L http://www.cbcb.umd.edu/~cmhill/files/lap_release_1.1.zip -o lap_release_1.1.zip")
os.system("unzip lap_release_1.1.zip")
os.system("mv ./lap_release_1.1 ./LAP")
os.system("rm -rf lap_release_1.1.zip")
if not os.path.exists("KronaTools") or 0:
if "kronatools" in packagesToInstall:
dl = 'y'
else:
print "KronaTools not found, needed for Postprocess, download now?"
dl = raw_input("Enter Y/N: ")
if dl == 'y' or dl == 'Y':
# TODO: KronaTools should be on the FTP site for robustness to URL changes
os.system("curl -L 'ftp://ftp.cbcb.umd.edu/pub/data/metamos/" + kronaTools + ".tar' -o %s.tar"%(kronaTools))
os.system("tar -xvf %s.tar"%(kronaTools))
os.system("rm -rf %s.tar"%(kronaTools))
os.system("mv %s KronaTools"%(kronaTools))
os.system("cd KronaTools && ./install.pl --prefix=.")
if not os.path.exists("KronaTools/taxonomy/taxonomy.tab") or 0:
if "kronatools" in packagesToInstall:
dl = 'y'
else:
print "KronaTools taxonomy data not found, needed for Postprocess, download now (will take around 20 minutes)?"
dl = raw_input("Enter Y/N: ")
if (dl == 'y' or dl == 'Y') and not nodbs:
os.system("cd KronaTools && ./updateTaxonomy.sh")
os.chdir("%s"%(METAMOS_ROOT))
os.system("cat KronaTools/taxonomy/taxonomy.tab |awk -F \"\\t\" '{print $1\"\\t\"$NF}' > ./Utilities/DB/tax_key.tab")
if not os.path.exists("./FastQC"):
if "fastqc" in packagesToInstall:
dl = 'y'
else:
print "FastQC not found, optional for Preprocess, download now?"
dl = raw_input("Enter Y/N: ")
if dl == 'y' or dl == 'Y':
archive = "fastqc_v0.10.0.zip"
os.system("curl -L http://www.bioinformatics.babraham.ac.uk/projects/fastqc/%s -o %s" % (archive,archive))
os.system("unzip %s" % archive)
os.system("rm %s" % archive)
os.system("chmod u+x FastQC/fastqc")
if not os.path.exists("./Utilities/DB/uniprot_sprot.fasta"):
if "uniprot" in packagesToInstall:
dl = 'y'
else:
print "Uniprot/Swissprot DB not found, optional for Functional Annotation, download now?"
dl = raw_input("Enter Y/N: ")
if (dl == 'y' or dl == 'Y') and not nodbs:
archive = "uniprot.tar.gz"
os.system("curl -L ftp://ftp.cbcb.umd.edu/pub/data/metamos/%s -o %s" %(archive, archive))
os.system("tar -C ./Utilities/DB/ -xvf %s" % archive)
os.system("rm %s"%archive)
# velvet
if not os.path.exists("./Utilities/cpp%s%s-%s%svelvet"%(os.sep, OSTYPE, MACHINETYPE, os.sep)):
if "velvet" in packagesToInstall:
dl = 'y'
else:
print "Velvet not found, optional for Assemble step, download now?"
dl = raw_input("Enter Y/N: ")
if dl == 'y' or dl == 'Y':
archive = "velvet.tar.gz"
os.system("curl -L ftp://ftp.cbcb.umd.edu/pub/data/metamos/velvet_1.2.10.tgz -o %s"%(archive))
os.system("rm -rf ./Utilities/cpp%s%s-%s%svelvet"%(os.sep, OSTYPE, MACHINETYPE, os.sep))
os.system("tar -xvzf %s"%(archive))
os.system("mv velvet_1.2.10 ./Utilities/cpp/%s%s-%s%svelvet"%(os.sep, OSTYPE, MACHINETYPE, os.sep))
os.chdir("./Utilities/cpp/%s%s-%s%svelvet"%(os.sep, OSTYPE, MACHINETYPE, os.sep))
updateMakeFileForDarwin("Makefile", addedCFlags, addedLDFlags)
os.system("make clean")
os.system("make CATEGORIES=16 MAXKMERLENGTH=127 OPENMP=1 BUNDLEDZLIB=1")
os.chdir("%s"%(METAMOS_ROOT))
os.system("rm %s"%archive)
# velvet-sc
if not os.path.exists("./Utilities/cpp%s%s-%s%svelvet-sc"%(os.sep, OSTYPE, MACHINETYPE, os.sep)):
if "velvet-sc" in packagesToInstall:
dl = 'y'
else:
print "Velvet-SC not found, optional for Assemble step, download now?"
dl = raw_input("Enter Y/N: ")
if dl == 'y' or dl == 'Y':
archive = "velvet-sc.tar.gz"
os.system("curl -L ftp://ftp.cbcb.umd.edu/pub/data/metamos/velvet-sc.tar.gz -o %s"%(archive))
os.system("rm -rf ./Utilities/cpp%s%s-%s%svelvet-sc"%(os.sep, OSTYPE, MACHINETYPE, os.sep))
os.system("tar -xvzf %s"%(archive))
os.system("mv velvet-sc ./Utilities/cpp/%s%s-%s%svelvet-sc"%(os.sep, OSTYPE, MACHINETYPE, os.sep))
os.chdir("./Utilities/cpp/%s%s-%s%svelvet-sc"%(os.sep, OSTYPE, MACHINETYPE, os.sep))
updateMakeFileForDarwin("Makefile", addedCFlags, addedLDFlags)
os.system("make clean")
os.system("make CATEGORIES=16 MAXKMERLENGTH=127 OPENMP=1")
os.chdir("%s"%(METAMOS_ROOT))
os.system("rm %s"%archive)
# metavelvet
if not os.path.exists("./Utilities/cpp%s%s-%s%sMetaVelvet"%(os.sep, OSTYPE, MACHINETYPE, os.sep)):
if "metavelvet" in packagesToInstall:
dl = 'y'
else:
print "MetaVelvet not found, optional for Assemble step, download now?"
dl = raw_input("Enter Y/N: ")
if dl == 'y' or dl == 'Y':
archive = "MetaVelvet-1.2.02.tgz"
os.system("curl -L ftp://ftp.cbcb.umd.edu/pub/data/metamos/MetaVelvet-1.2.02.tgz -o %s"%(archive))
os.system("rm -rf ./Utilities/cpp%s%s-%s%sMetaVelvet"%(os.sep, OSTYPE, MACHINETYPE, os.sep))
os.system("tar -xvzf %s"%(archive))
os.system("mv MetaVelvet-1.2.02 ./Utilities/cpp/%s%s-%s%sMetaVelvet"%(os.sep, OSTYPE, MACHINETYPE, os.sep))
os.chdir("./Utilities/cpp/%s%s-%s%sMetaVelvet"%(os.sep, OSTYPE, MACHINETYPE, os.sep))
if OSTYPE == "Darwin":
os.system("cp Utils/Utils.hh Utils/Utils.hh.orig")
os.system("cat Utils/Utils.hh.orig |awk '{if (match($0, \"#define MAX_STRING_LENGTH\")) { print \"#include <sys/types.h>\\n\"$0; } else { print $0; }}' > Utils/Utils.hh")
updateMakeFileForDarwin("Makefile", addedCFlags, addedLDFlags)
os.system("make clean")
os.system("make CATEGORIES=16 MAXKMERLENGTH=127")
os.chdir("%s"%(METAMOS_ROOT))
os.system("rm %s"%archive)
if "viritas" in enabledWorkflows or manual:
if not os.path.exists("./Utilities/cpp%s%s-%s%strnascan"%(os.sep, OSTYPE, MACHINETYPE, os.sep)):
if "trnascan" in packagesToInstall:
dl = 'y'
else:
print "tRNAscan not found, optional for Annotate step, download now?"
dl = raw_input("Enter Y/N: ")
if dl == 'y' or dl == 'Y':
os.system("curl -L http://lowelab.ucsc.edu/software/tRNAscan-SE.tar.gz -o trnascan.tar")
os.system("tar xvf trnascan.tar")
os.system("mv tRNAscan-SE-1.3.1 ./Utilities/cpp/%s%s-%s%strnascan"%(os.sep, OSTYPE, MACHINETYPE, os.sep))
os.chdir("./Utilities/cpp/%s%s-%s%strnascan"%(os.sep, OSTYPE, MACHINETYPE, os.sep))
updateMakeFileForDarwin("Makefile", addedCFlags, addedLDFlags)
os.system("make")
os.chdir("%s"%(METAMOS_ROOT))
os.system("rm -rf trnascan.tar")
# now workflow specific tools
if "optional" in enabledWorkflows or manual:
if not os.path.exists("./Utilities/cpp/%s-%s/metaphylerClassify"%(OSTYPE, MACHINETYPE)) or not os.path.exists("./Utilities/perl/metaphyler/markers/markers.protein") or not os.path.exists("./Utilities/perl/metaphyler/markers/markers.dna"):
if "metaphyler" in packagesToInstall:
dl = 'y'
else:
print "Metaphyler (latest version) not found, optional for Annotate, download now?"
dl = raw_input("Enter Y/N: ")
if dl == 'y' or dl == 'Y':
os.system("curl -L http://metaphyler.cbcb.umd.edu/MetaPhylerV1.25.tar.gz -o metaphyler.tar.gz")
os.system("tar -C ./Utilities/perl/ -xvf metaphyler.tar.gz")
os.system("mv ./Utilities/perl/MetaPhylerV1.25 ./Utilities/perl/metaphyler")
os.system("mv ./Utilities/perl/metaphyler/installMetaphyler.pl ./Utilities/perl/metaphyler/installMetaphylerFORMATDB.pl");
os.system("cat ./Utilities/perl/metaphyler/installMetaphylerFORMATDB.pl |sed 's/formatdb/\.\/Utilities\/cpp\/%s-%s\/formatdb/g' > ./Utilities/perl/metaphyler/installMetaphyler.pl"%(OSTYPE, MACHINETYPE));
os.system("perl ./Utilities/perl/metaphyler/installMetaphyler.pl")
os.system("cp ./Utilities/perl/metaphyler/metaphylerClassify ./Utilities/cpp/%s-%s/metaphylerClassify"%(OSTYPE, MACHINETYPE))
if not os.path.exists("./Utilities/models") or not os.path.exists("./Utilities/DB/blast_data"):
if "fcp" in packagesToInstall:
dl = 'y'
else:
print "Genome models not found, optional for FCP/NB, download now?"
dl = raw_input("Enter Y/N: ")
if (dl == 'y' or dl == 'Y') and not nodbs:
archive = "fcp_models.tar.gz"
os.system("curl -L ftp://ftp.cbcb.umd.edu/pub/data/metamos/%s -o %s" %(archive, archive))
os.system("rm -rf ./Utilities/DB/blast_data")
os.system("rm -rf ./Utilities/models")
os.system("tar -C ./Utilities/ -xvf %s" % archive)
os.system("rm %s"%archive)
if not os.path.exists("./phylosift") or not os.path.exists("./phylosift/lib/version.pm") or not os.path.exists("./phylosift/lib/Params"):
if "phylosift" in packagesToInstall:
dl = 'y'
else:
print "PhyloSift binaries not found, optional for Annotate step, download now?"
dl = raw_input("Enter Y/N: ")
if dl == 'y' or dl == 'Y':
if not os.path.exists("./phylosift"):
#phylosift OSX binaries included inside Linux X86_64 tarball..
os.system("curl -L http://edhar.genomecenter.ucdavis.edu/~koadman/phylosift/devel/phylosift_20130829.tar.bz2 -o ./phylosift.tar.bz2")
os.system("tar -xvjf phylosift.tar.bz2")
os.system("rm -rf phylosift.tar.bz2")
os.system("mv phylosift_20130829 phylosift")
if not os.path.exists("./phylosift/legacy/version.pm"):
#phylosift needs version but doesn't include it
os.system("curl -L http://www.cpan.org/authors/id/J/JP/JPEACOCK/version-0.9903.tar.gz -o version.tar.gz")
os.system("tar xvzf version.tar.gz")
os.chdir("./version-0.9903/")
os.system("perl Makefile.PL")
os.system("make")
os.system("cp -r blib/lib/* ../phylosift/lib")
os.chdir(METAMOS_ROOT)
os.system("rm -rf version.tar.gz")
os.system("rm -rf version-0.9903")
if not os.path.exists("./phylosift/lib/Params"):
os.system("curl -L ftp://ftp.cbcb.umd.edu/pub/data/metamos/params-validate.tar.gz -o ./params-validate.tar.gz")
os.system("tar xvzf params-validate.tar.gz")
os.system("rm -rf params-validate.tar.gz")
# download markers dbs
if not os.path.exists("./phylosift/share"):
markerUrl = utils.getCommandOutput("cat phylosift/phylosiftrc |grep marker_base |awk '{print $NF}' |sed s/\;//g", False)
ncbiUrl = utils.getCommandOutput("cat phylosift/phylosiftrc |grep ncbi_url |awk '{print $NF}' |sed s/\;//g", False)
os.system("mkdir -p ./phylosift/share/phylosift")
os.chdir("./phylosift/share/phylosift")
os.system("curl -L %s/markers.tgz -o marker.tgz"%(markerUrl))
os.system("tar xvzf marker.tgz")
os.system("rm marker.tgz")
os.system("curl -L %s -o ncbi.tgz"%(ncbiUrl))
os.system("tar xvzf ncbi.tgz")
os.system("rm ncbi.tgz")
os.chdir(METAMOS_ROOT)
# check the number of files the DB currently is and see if we have the expected number
dbResult = ""
if not nodbs:
dbResult = utils.getCommandOutput("perl ./Utilities/perl/update_blastdb.pl refseq_protein --numpartitions", False)
if not nodbs and dbResult == "":
print "Error: could not connect to NCBI, will not be installing refseq protein DB"
elif not nodbs:
(dbName, numPartitions) = dbResult.split("\t", 1)
print "Checking whether %s is complete. Expecting %d partitions.\n"%(dbName, int(numPartitions))
numPartitions = int(numPartitions) - 1
if not os.path.exists("./Utilities/DB/refseq_protein.pal") or not os.path.exists("./Utilities/DB/refseq_protein.%02d.psq"%(int(numPartitions))) or not os.path.exists("./Utilities/DB/allprots.faa"):
if "phmmer" in packagesToInstall:
dl = 'y'
else:
print "refseq protein DB not found or incomplete, needed for Annotate step, download now?"
dl = raw_input("Enter Y/N: ")
if dl == 'y' or dl == 'Y':
print "Download and install refseq protein DB.."
os.system("perl ./Utilities/perl/update_blastdb.pl refseq_protein")
os.system("mv refseq_protein.*.tar.gz ./Utilities/DB/")
fileList = glob.glob("./Utilities/DB/refseq_protein.*.tar.gz")
for file in fileList:
os.system("tar -C ./Utilities/DB/ -xvf %s"%(file))
print " running fastacmd (might take a few min)..."
os.system(".%sUtilities%scpp%s%s-%s%sfastacmd -d ./Utilities/DB/refseq_protein -p T -a T -D 1 -o ./Utilities/DB/allprots.faa"%(os.sep, os.sep, os.sep, OSTYPE, MACHINETYPE, os.sep))
# sra toolkit
if not os.path.exists("./Utilities/cpp%s%s-%s%ssra"%(os.sep, OSTYPE, MACHINETYPE, os.sep)):
sra = utils.getFromPath("srapath", "SRA PATH", False)
if sra == "":
if "sra" in packagesToInstall:
dl = 'y'
else:
print "SRA binaries not found, optional for initPipeline step, download now?"
dl = raw_input("Enter Y/N: ")
if dl == 'y' or dl == 'Y':
if OSTYPE == 'Linux' and MACHINETYPE == "x86_64":
os.system("curl -L http://ftp-trace.ncbi.nlm.nih.gov/sra/sdk/2.3.3-3/sratoolkit.2.3.3-3-centos_linux64.tar.gz -o sra.tar.gz")
elif OSTYPE == "Darwin" and MACHINETYPE == "x86_64":
os.system("curl -L http://ftp-trace.ncbi.nlm.nih.gov/sra/sdk/2.3.3-3/sratoolkit.2.3.3-3-mac64.tar.gz -o sra.tar.gz")
os.system("tar xvzf sra.tar.gz")
os.system("mv sratoolkit.2.3.3-3-* ./Utilities/cpp%s%s-%s%ssra"%(os.sep, OSTYPE, MACHINETYPE, os.sep))
os.system("rm -rf sra.tar.gz")
if "isolate" in enabledWorkflows or "imetamos" in enabledWorkflows or manual:
# check for cmake
if not os.path.exists("./Utilities/cpp%s%s-%s%scmake"%(os.sep, OSTYPE, MACHINETYPE, os.sep)):
cmake = utils.getFromPath("cmake", "CMAKE", False)
if cmake == "":
if "cmake" in packagesToInstall:
dl = 'y'
else:
print "cmake binaries not found, optional for initPipeline step, download now?"
dl = raw_input("Enter Y/N: ")
if dl == 'y' or dl == 'Y':
os.system("curl -L http://www.cmake.org/files/v2.8/cmake-2.8.12.tar.gz -o cmake.tar.gz")
os.system("tar xvzf cmake.tar.gz")
os.system("mv cmake-2.8.12 ./Utilities/cpp%s%s-%s%scmake"%(os.sep, OSTYPE, MACHINETYPE, os.sep))
os.chdir("./Utilities/cpp%s%s-%s%scmake"%(os.sep, OSTYPE, MACHINETYPE, os.sep))
os.system("./bootstrap --prefix=`pwd`/build;make;make install")
os.chdir("%s"%(METAMOS_ROOT))
os.system("rm cmake.tar.gz")
if os.path.exists("./Utilities/cpp%s%s-%s%scmake"%(os.sep, OSTYPE, MACHINETYPE, os.sep)):
pathUpdate = "%s/Utilities/cpp%s%s-%s%scmake/build/bin"%(METAMOS_ROOT, os.sep, OSTYPE, MACHINETYPE, os.sep)
if "PATH" in os.environ:
pathUpdate = "%s%s%s"%(os.environ["PATH"], os.pathsep, pathUpdate)
os.environ["PATH"]=pathUpdate
os.chdir("%s"%(METAMOS_ROOT))
if not os.path.exists("./CA"):
if "ca" in packagesToInstall:
dl = 'y'
else:
print "Celera Assembler binaries not found, optional for Assemble step, download now?"
dl = raw_input("Enter Y/N: ")
if dl == 'y' or dl == 'Y':
os.system("curl -L https://downloads.sourceforge.net/project/wgs-assembler/wgs-assembler/wgs-8.1/wgs-8.1.tar.bz2 -o wgs-8.1.tar.bz2")
os.system("tar xvjf wgs-8.1.tar.bz2")
os.system("rm -rf wgs-8.1.tar.bz2")
os.system("mv wgs-8.1 CA")
# patch CA to support PacBio sequences and non-apple compilers on OSX
if not ALLOW_FAST:
os.system("cd CA/kmer/ && cp configure.sh configure.original")
os.system("cd CA/kmer/ && cat configure.original |sed s/\-fast//g > configure.sh")
os.system("cd CA/src/ && cp c_make.as c_make.original")
os.system("cd CA/src/ && cat c_make.original |sed s/\-fast//g > c_make.as")
if not HAVE_GCC42:
os.system("cd CA/src/ && cp c_make.as c_make.original")
os.system("cd CA/src/ && cat c_make.original |sed s/\-4.2//g > c_make.as")
if GCC_VERSION >= 4.7:
os.system("cd CA/src/ && cp c_make.as c_make.original")
os.system("cd CA/src/ && cat c_make.original |sed s/\-rdynamic//g > c_make.as")
updateMakeFileForDarwin("CA/kmer/Makefile", addedCFlags, addedLDFlags)
updateMakeFileForDarwin("CA/samtools/Makefile", addedCFlags, addedLDFlags)
updateMakeFileForDarwin("CA/src/c_make.as", addedCFlags, addedLDFlags)
os.system("cd CA/samtools && make")
os.system("cd CA/kmer && ./configure.sh && gmake install")
os.system("cd CA/src && gmake")
if not os.path.exists("./Utilities/cpp%s%s-%s%sRay"%(os.sep, OSTYPE, MACHINETYPE, os.sep)):
if "ray" in packagesToInstall:
dl = 'y'
else:
print "Ray binaries not found, optional for Assemble step, download now?"
dl = raw_input("Enter Y/N: ")
if dl == 'y' or dl == 'Y':
# check for mpi which is required
command="mpicxx"
mpi=utils.getFromPath(command, "MPI", False)
if not os.path.exists("%s%s%s"%(mpi, os.sep, command)):
command="openmpicxx"
mpi=utils.getFromPath(command, "MPI", False)
if not os.path.exists("%s%s%s"%(mpi, os.sep, command)):
mpi = command = ""
print "Error: cannot find MPI, required to build Ray. Please add it to your path."
if command != "":
os.system("curl -L http://downloads.sourceforge.net/project/denovoassembler/Ray-v2.2.0.tar.bz2 -o Ray-v2.2.0.tar.bz2")
os.system("tar xvjf Ray-v2.2.0.tar.bz2")
os.system("mv Ray-v2.2.0 ./Utilities/cpp/%s%s-%s%sRay"%(os.sep, OSTYPE, MACHINETYPE, os.sep))
os.chdir("./Utilities/cpp/%s%s-%s%sRay"%(os.sep, OSTYPE, MACHINETYPE, os.sep))
os.system("make PREFIX=bin MPICXX=%s%s%s MAXKMERLENGTH=128 MPI_IO=y DEBUG=n ASSERT=n EXTRA=\" -march=native\""%(mpi, os.sep, command))
os.system("make install")
os.chdir("%s"%(METAMOS_ROOT))
os.system("rm -rf Ray-v2.2.0.tar.bz2")
if not os.path.exists("./Utilities/cpp%s%s-%s%skmergenie"%(os.sep, OSTYPE, MACHINETYPE, os.sep)):
kmerGenie = utils.getFromPath("kmergenie", "Kmer Genie", False)
if kmerGenie == "":
if "kmergenie" in packagesToInstall:
dl = 'y'
else:
print "Kmer Genie was not found, optional for Assemble step, download now?"
dl = raw_input("Enter Y/N: ")
if dl == 'y' or dl == 'Y':
os.system("curl -L ftp://ftp.cbcb.umd.edu/pub/data/metamos/kmergenie-1.5692.tar.gz -o kmer.tar.gz")
os.system("tar xvzf kmer.tar.gz")
os.system("mv kmergenie-1.5692 ./Utilities/cpp%s%s-%s%skmergenie"%(os.sep, OSTYPE, MACHINETYPE, os.sep))
os.chdir("./Utilities/cpp%s%s-%s%skmergenie"%(os.sep, OSTYPE, MACHINETYPE, os.sep))
updateMakeFileForDarwin("makefile", addedCFlags, addedLDFlags)
os.system("make k=300")
os.chdir("%s"%(METAMOS_ROOT))
os.system("rm -rf kmer.tar.gz")
if not os.path.exists("./Utilities/cpp%s%s-%s%sspades"%(os.sep, OSTYPE, MACHINETYPE, os.sep)):
spades = utils.getFromPath("spades.py", "SPAdes", False)
if spades == "":
if "spades" in packagesToInstall:
dl = 'y'
else:
print "SPAdes was not found, optional for Assemble step, download now?"
dl = raw_input("Enter Y/N: ")
if dl == 'y' or dl == 'Y':
if OSTYPE == "Darwin":
if GCC_VERSION < 4.7:
print "Error: SPAdes requires gcc at least version 4.7, found version %s. Please update and try again"%(GCC_VERSION)
else:
os.system("curl -L http://spades.bioinf.spbau.ru/release3.0.0/SPAdes-3.0.0.tar.gz -o spades.tar.gz")
os.system("tar xvzf spades.tar.gz")
os.system("mv SPAdes-3.0.0 ./Utilities/cpp%s%s-%s%sspades"%(os.sep, OSTYPE, MACHINETYPE, os.sep))
os.chdir("./Utilities/cpp%s%s-%s%sspades"%(os.sep, OSTYPE, MACHINETYPE, os.sep))
os.system("export CC=`which gcc` && bash spades_compile.sh")
os.chdir("%s"%(METAMOS_ROOT))
else:
os.system("curl -L http://spades.bioinf.spbau.ru/release3.0.0/SPAdes-3.0.0-Linux.tar.gz -o spades.tar.gz")
os.system("tar xvzf spades.tar.gz")
os.system("mv SPAdes-3.0.0-Linux ./Utilities/cpp%s%s-%s%sspades"%(os.sep, OSTYPE, MACHINETYPE, os.sep))
os.system("rm -rf spades.tar.gz")
if not os.path.exists("./Utilities/cpp%s%s-%s%sprokka"%(os.sep, OSTYPE, MACHINETYPE, os.sep)):
prokaBin = utils.getFromPath("prokka", "Prokka", False)
dl = 'n'
if prokaBin == "":
if "prokka" in packagesToInstall:
dl = 'y'
else:
print "Prokka binaries not found, optional for Assemble step, download now?"
dl = raw_input("Enter Y/N: ")
if dl == 'y' or dl == 'Y':
signalp = utils.getFromPath("signalp", "SignalP", False)
if signalp == "":
print "Warning: SignalP is not installed and is required for Prokka's gram option. Please download it and add it to your path."
os.system("curl -L ftp://ftp.cbcb.umd.edu/pub/data/metamos/prokka-1.7.tar.gz -o prokka-1.7.tar.gz")
os.system("tar xvzf prokka-1.7.tar.gz")
os.system("mv prokka-1.7 ./Utilities/cpp%s%s-%s%sprokka"%(os.sep, OSTYPE, MACHINETYPE, os.sep))
os.system("rm prokka-1.7.tar.gz")
bioperl = utils.getCommandOutput("perl -MBio::Seq -e 0 && echo $?", True)
perltime = utils.getCommandOutput("perl -MTime::Piece -e 0 && echo $?", True)
xmlsimple = utils.getCommandOutput("perl -MXML::Simple -e 0 && echo $?", True)
storable = utils.getCommandOutput("perl -MStorable -e 0 && echo $?", True)
xmlparser = utils.getCommandOutput("perl -MXML:Parser -e 0 && echo $?", True)
# always install bioperl, otherwise parts may be missing or it may be the wrong version
# phylosift comes with BioPerl, use it
os.system("curl -L http://edhar.genomecenter.ucdavis.edu/~koadman/phylosift/devel/phylosift_20130829.tar.bz2 -o ./phylosift.tar.bz2")
os.system("tar -xvjf phylosift.tar.bz2")
os.system("rm -rf phylosift.tar.bz2")
os.system("mv phylosift_20130829/lib ./Utilities/cpp%s%s-%s%sprokka"%(os.sep, OSTYPE, MACHINETYPE, os.sep))
os.system("rm -rf phylosift_20130829")
if perltime == "":
os.system("curl -L http://search.cpan.org/CPAN/authors/id/M/MS/MSERGEANT/Time-Piece-1.08.tar.gz -o time.tar.gz")
os.system("tar -xvzf time.tar.gz")
os.chdir("Time-Piece-1.08")
os.system("perl Makefile.PL PREFIX=`pwd`/build")
os.system("make install")
os.chdir("%s"%(METAMOS_ROOT))
pathToCopy = utils.getCommandOutput("find Time-Piece-1.08/build -type d -name \"Time\" |grep -v auto", False)
copyPerlLib(pathToCopy, "./Utilities/cpp%s%s-%s%sprokka/lib/"%(os.sep, OSTYPE, MACHINETYPE, os.sep))
os.system("rm -rf time.tar.gz")
os.system("rm -rf Time-Piece-1.08")
if xmlparser == "":
os.system("curl -L http://search.cpan.org/CPAN/authors/id/M/MS/MSERGEANT/XML-Parser-2.36.tar.gz -o parse.tar.gz")
os.system("tar -xvzf parse.tar.gz")
os.chdir("XML-Parser-2.36")
os.system("perl Makefile.PL PREFIX=`pwd`/build")
os.system("make install")
os.chdir("%s"%(METAMOS_ROOT))
pathToCopy = utils.getCommandOutput("find XML-Parser-2.36/build -type d -name \"XML\" |grep -v auto", False)
copyPerlLib(pathToCopy, "./Utilities/cpp%s%s-%s%sprokka/lib/"%(os.sep, OSTYPE, MACHINETYPE, os.sep))
libUpdate = "%s/Utilities/cpp%s%s-%s%sprokka/lib/"%(METAMOS_ROOT, os.sep, OSTYPE, MACHINETYPE, os.sep)
if "PERL5LIB" in os.environ:
libUpdate = "%s%s%s"%(os.environ["PERL5LIB"], os.pathsep, libUpdate)
os.environ["PERL5LIB"]=libUpdate
os.system("rm -rf parse.tar.gz")
os.system("rm -rf XML-Parser-2.36")
if xmlsimple == "":
os.system("curl -L http://search.cpan.org/CPAN/authors/id/G/GR/GRANTM/XML-Simple-1.08.tar.gz -o xml.tar.gz")
os.system("tar -xvzf xml.tar.gz")
os.chdir("XML-Simple-1.08")
os.system("perl Makefile.PL PREFIX=`pwd`/build")
os.system("make install")
os.chdir("%s"%(METAMOS_ROOT))
pathToCopy = utils.getCommandOutput("find XML-Simple-1.08/build -type d -name \"XML\" |grep -v auto", False)
copyPerlLib(pathToCopy, "./Utilities/cpp%s%s-%s%sprokka/lib/"%(os.sep, OSTYPE, MACHINETYPE, os.sep))
os.system("rm -rf xml.tar.gz")
os.system("rm -rf XML-Simple-1.08")
if os.path.exists("./Utilities/cpp%s%s-%s%sprokka/lib"%(os.sep, OSTYPE, MACHINETYPE, os.sep)):
os.chdir("./Utilities/cpp%s%s-%s%sprokka/bin"%(os.sep, OSTYPE, MACHINETYPE, os.sep))
os.system("cp prokka prokka.original")
os.system("cat prokka.original |awk '{if (match($0, \"use strict\")) { print \"use lib \\\"%s/Utilities/cpp%s%s-%s%sprokka/lib\\\";\"; print $0; } else { print $0}}' > prokka"%(METAMOS_ROOT, os.sep, OSTYPE, MACHINETYPE, os.sep))
os.chdir("%s"%(METAMOS_ROOT))
# for some reason prokka adds its binaries to the end of path, not beginning so if your path has the wrong version of a program, it will crash. Update
os.chdir("./Utilities/cpp%s%s-%s%sprokka/bin"%(os.sep, OSTYPE, MACHINETYPE, os.sep))
os.system("cp prokka prokka.original")
os.system("cat prokka.original |awk '{if (match($0, \"ENV{PATH}\")) { print \"$ENV{PATH} = $BINDIR . \\\":\\\" . $ENV{PATH};\"; } else { print $0}}' > prokka")
os.chdir("%s"%(METAMOS_ROOT))
aragorn = utils.getFromPath("aragorn", "aragorn", False)
aragornVersion = ""
if aragorn != "":
aragornVersion = utils.getCommandOutput("%s/aragorn -h 2>&1 | grep -i '^ARAGORN v' |sed s/v//g |awk '{printf(\"%%2.2f\n\", $2)}'", True)
if float(aragornVersion) < 1.2:
aragorn = ""
if aragorn == "":
print "Aragorn missing, will install"
os.system("curl -L http://130.235.46.10/ARAGORN/Downloads/aragorn1.2.36.tgz -o aragorn.tar.gz")
os.system("tar xvzf aragorn.tar.gz")
os.chdir("aragorn1.2.36")
os.system("gcc -O3 -ffast-math -finline-functions %s %s -o aragorn aragorn1.2.36.c"%(addedCFlags, addedLDFlags))
os.chdir("%s"%(METAMOS_ROOT))
os.system("mv aragorn1.2.36/aragorn ./Utilities/cpp%s%s-%s%sprokka/binaries%s%s"%(os.sep, OSTYPE, MACHINETYPE, os.sep, os.sep, OSTYPE.lower()))
os.system("rm -rf aragorn1.2.36")
os.system("rm aragorn.tar.gz")
infernal = utils.getFromPath("cmscan", "Infernal", False)
if infernal == "" and not os.path.exists("./Utilities/cpp%s%s-%s%sprokka/binaries/%s/infernal"%(os.sep, OSTYPE, MACHINETYPE, os.sep, OSTYPE.lower())):
print "Infernal missing, will install"
if OSTYPE == "Darwin":
os.system("curl -L http://selab.janelia.org/software/infernal/infernal-1.1rc4-macosx-intel.tar.gz -o infernal.tar.gz")
else:
os.system("curl -L http://selab.janelia.org/software/infernal/infernal-1.1rc4-linux-intel-gcc.tar.gz -o infernal.tar.gz")
os.system("tar xvzf infernal.tar.gz")
os.system("mv infernal*/binaries/* ./Utilities/cpp%s%s-%s%sprokka/binaries%s%s"%(os.sep, OSTYPE, MACHINETYPE, os.sep, os.sep, OSTYPE.lower()))
os.system("rm -rf infernal*")
barrnap = utils.getFromPath("barrnap", "barrnap", False)
if barrnap == "" and not os.path.exists("./Utilities/cpp%s%s-%s%sprokka/binaries/%s/barrnap"%(os.sep, OSTYPE, MACHINETYPE, os.sep, OSTYPE.lower())):
print "Barrnap missing, will install"
os.system("curl -L http://www.vicbioinformatics.com/barrnap-0.1.tar.gz -o barrnap.tar.gz")
os.system("tar xvzf barrnap.tar.gz")
os.system("mv barrnap-0.1/barrnap ./Utilities/cpp%s%s-%s%sprokka/binaries%s%s"%(os.sep, OSTYPE, MACHINETYPE, os.sep, os.sep, OSTYPE.lower()))
os.system("mv barrnap-0.1/db ./Utilities/cpp%s%s-%s%sprokka/binaries%s%s"%(os.sep, OSTYPE, MACHINETYPE, os.sep, os.sep, OSTYPE.lower()))
if os.path.exists("./Utilities/cpp%s%s-%s%sprokka/lib"%(os.sep, OSTYPE, MACHINETYPE, os.sep)):
os.chdir("./Utilities/cpp%s%s-%s%sprokka/binaries%s%s"%(os.sep, OSTYPE, MACHINETYPE, os.sep, os.sep, OSTYPE.lower()))
os.system("cp barrnap barrnap.original")
os.system("cat barrnap.original |awk '{if (match($0, \"use strict\")) { print \"use lib \\\"%s/Utilities/cpp%s%s-%s%sprokka/lib\\\";\"; print $0; } else { print $0}}' > barrnap"%(METAMOS_ROOT, os.sep, OSTYPE, MACHINETYPE, os.sep))
os.chdir("%s"%(METAMOS_ROOT))
os.system("rm -rf barrnap-0.1")
os.system("rm barrnap.tar.gz")
hmmscan = utils.getFromPath("hmmscan", "HMMER3", False)