comparison phylogenies/beast.py @ 0:5b9a38ec4a39 draft default tip

First commit of old repositories
author osiris_phylogenetics <ucsb_phylogenetics@lifesci.ucsb.edu>
date Tue, 11 Mar 2014 12:19:13 -0700
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:5b9a38ec4a39
1 #!/usr/bin/python
2 """
3 This program makes a new copy of a BEAST XML config file and changes the name of the log and tree files.
4 The names have to be changed since Galaxy does not support dynamic output file names.
5 The new XML file name must not be the same as the original!!!
6 Script prints unique filename.
7
8
9 Usage: python beast.py XMLFILE SAVE_DIRECTORY
10 """
11
12 import sys
13 import time
14 from xml.etree.ElementTree import ElementTree
15
16 beastDOM = ElementTree()
17 beastDOM.parse(sys.argv[1])
18 logs = beastDOM.findall('mcmc/log')
19 for log in logs:
20 if log.get('id', False) == "fileLog":
21 log.set('fileName', 'data.log')
22
23 logs = beastDOM.findall('mcmc/logTree')
24 for log in logs:
25 if log.get('id', False) == "treeFileLog":
26 log.set('fileName', 'data.trees')
27
28 if len(sys.argv) > 2:
29 directory = sys.argv[2]
30 else:
31 directory = ""
32
33 filename = directory + "/" + str(time.time()) + '.xml'
34 beastDOM.write(filename)
35 print filename