allpy
changeset 473:d3c7e08058c2
mass_realign_blocks: Added flag --exclude to list sequence name to exclude when realigning
author | Daniil Alexeyevsky <dendik@kodomo.fbb.msu.ru> |
---|---|
date | Thu, 17 Feb 2011 18:35:59 +0300 |
parents | a24598827bf1 |
children | d3d73a144095 |
files | utils/mass_realign_blocks.py |
diffstat | 1 files changed, 8 insertions(+), 1 deletions(-) [+] |
line diff
1.1 --- a/utils/mass_realign_blocks.py Thu Feb 17 11:37:48 2011 +0300 1.2 +++ b/utils/mass_realign_blocks.py Thu Feb 17 18:35:59 2011 +0300 1.3 @@ -36,13 +36,18 @@ 1.4 tasks.append((filename, int(begin), int(end))) 1.5 return tasks 1.6 1.7 +def sequences_excluded(sequences): 1.8 + exclude = map(str.strip, options.exclude.split(",")) 1.9 + return [s for s in sequences if s.name not in exclude] 1.10 + 1.11 def main(): 1.12 tasks = read_task(open(options.task_file)) 1.13 for filename, begin, end in tasks: 1.14 with open(filename) as in_file: 1.15 alignment = protein.Alignment().append_file(in_file) 1.16 columns = alignment.columns[begin-1:end] 1.17 - block = protein.Block.from_alignment(alignment, columns=columns) 1.18 + sequences = sequences_excluded(alignment.sequences) 1.19 + block = protein.Block.from_alignment(alignment, columns=columns, sequences=sequences) 1.20 block.process(Muscle(), False, False) 1.21 with open(filename, "w") as out_file: 1.22 alignment.to_file(out_file) 1.23 @@ -52,6 +57,8 @@ 1.24 parser = optparse.OptionParser(usage=usage) 1.25 parser.add_option("-t", "--task-file", 1.26 help="Task description file. Each line has filename, start position, end position, separated with tabs.") 1.27 + parser.add_option("-x", "--exclude", 1.28 + help="Comma-separated list of sequence names to exclude when realigning.") 1.29 options, args = parser.parse_args() 1.30 1.31 if args: