-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfilepair.py
69 lines (54 loc) · 1.59 KB
/
filepair.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
"Store a tree and alignment pair"
import os
class FilePair(object):
"""
Stores a corresponding tree and alignment file pair.
"""
def __init__(self, tree_file="", alignment_file=""):
self._tree = str(tree_file)
self._alignment = str(alignment_file)
def __str__(self):
return self.filename
def __nonzero__(self):
return True
def __bool__(self):
return True
@property
def tree(self):
"The path to a Newick-formatted file."
return self._tree
@tree.setter
def tree(self, value):
self._tree = value
@property
def alignment(self):
"The path to an alignment file in FASTA format."
return self._alignment
@alignment.setter
def alignment(self, value):
self._alignment = value
def has_alignment(self):
return self.alignment
def has_tree(self):
return self.tree
def is_filled(self):
return self.tree and self.alignment
def dirname(self):
if self.alignment:
return os.path.dirname(self.alignment)
elif self.tree:
return os.path.dirname(self.tree)
else:
return ""
def filename(self):
if self.alignment:
return os.path.basename(os.path.splitext(self.alignment)[0])
elif self.tree:
return os.path.basename(os.path.splitext(self.tree)[0])
else:
return ""
def alignment_ext(self):
if self.alignment:
return os.path.basename(os.path.splitext(self.alignment)[0])
else:
return ""