You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This script will add dummy sequences '?' for missing taxa in each alignments, making sure that all alignments in the input folder contain the same taxa (as required for e.g. *BEAST)
5
+
"""
6
+
7
+
importos
8
+
importsys
9
+
importglob
10
+
importshutil
11
+
importconfigparser
12
+
importpickle
13
+
from .utilsimportCompletePath
14
+
15
+
defadd_arguments(parser):
16
+
parser.add_argument(
17
+
'--input',
18
+
required=True,
19
+
action=CompletePath,
20
+
default=None,
21
+
help='The directory containing fasta alignments'
22
+
)
23
+
parser.add_argument(
24
+
'--output',
25
+
required=True,
26
+
action=CompletePath,
27
+
default=None,
28
+
help='The output directory where results will be safed'
29
+
)
30
+
31
+
32
+
defread_fasta(fasta):
33
+
name, seq=None, []
34
+
forlineinfasta:
35
+
line=line.rstrip()
36
+
ifline.startswith(">"):
37
+
ifname: yield (name, ''.join(seq))
38
+
name, seq=line, []
39
+
else:
40
+
seq.append(line)
41
+
ifname: yield (name, ''.join(seq))
42
+
43
+
44
+
defmain(args):
45
+
# Set working directory
46
+
work_dir=args.input
47
+
out_dir=args.output
48
+
ifnotos.path.exists(out_dir):
49
+
os.makedirs(out_dir)
50
+
51
+
# Create a dictionary with the name-pattern as key and all file-names sharing that name-pattern
0 commit comments