allpy
changeset 1111:7bc44212ca15
Automated merge with ssh://kodomo/allpy
author | Mmmasha! |
---|---|
date | Tue, 19 Jun 2012 16:55:44 +0400 |
parents | 0736e1bbd186 e0eb2d0f0822 |
children | 2fbe82ce71ae |
files | allpy/fileio/markup.py |
diffstat | 2 files changed, 14 insertions(+), 5 deletions(-) [+] |
line diff
1.1 --- a/allpy/fileio/markup.py Thu Jun 14 20:24:26 2012 +0400 1.2 +++ b/allpy/fileio/markup.py Tue Jun 19 16:55:44 2012 +0400 1.3 @@ -101,7 +101,7 @@ 1.4 if sequence.name == record['sequence_name']: 1.5 description = record.get('sequence_description') 1.6 if description: 1.7 - assert sequence.description == description 1.8 + assert sequence.description == description, "Descriptions don't match: {0} != {1} for {2}".format(sequence.description, description, sequence.name) 1.9 cls = get_markups_class(record['class']) 1.10 cls.from_record(sequence, record, name=record.get('name')) 1.11 return
2.1 --- a/utils/markup_to_html.py Thu Jun 14 20:24:26 2012 +0400 2.2 +++ b/utils/markup_to_html.py Tue Jun 19 16:55:44 2012 +0400 2.3 @@ -13,10 +13,14 @@ 2.4 template_file = join(template_prefix, "markup_to_html.html") 2.5 2.6 parser = optparse.OptionParser(description=__doc__, usage="%prog [options] [infile]") 2.7 +parser.add_option("-t", "--template-file", default=template_file, 2.8 + help="HTML template file") 2.9 parser.add_option("-o", "--outfile", 2.10 help="Output file name, default: stdout") 2.11 +parser.add_option("-p", "--import-path", default=".", 2.12 + help="Path to imported module") 2.13 parser.add_option("-m", "--import-module", 2.14 - help="Import this module before anything, useful for custom markup classes") 2.15 + help="import this module before anything, useful for custom markup classes") 2.16 options, args = parser.parse_args() 2.17 2.18 outfile = options.outfile and open(options.outfile, "w") or sys.stdout 2.19 @@ -24,9 +28,11 @@ 2.20 if len(args) > 1: 2.21 parser.error("Too many arguments on the command line") 2.22 2.23 +module = None 2.24 + 2.25 if options.import_module: 2.26 - sys.path.append(".") 2.27 - __import__(options.import_module) 2.28 + sys.path.insert(0, options.import_path) 2.29 + module = __import__(options.import_module) 2.30 2.31 aln = protein.Alignment().append_file(infile, format="markup") 2.32 2.33 @@ -43,6 +49,9 @@ 2.34 items += repr_items([('sequence ' + k, v) for k, v in vars(sequence).items() if k != 'markups']) 2.35 monomer.description = "\n".join(items) 2.36 2.37 +if hasattr(module, 'init'): 2.38 + module.init(aln) 2.39 + 2.40 rows = aln.rows_as_lists() 2.41 -template = Template(open(template_file).read()) 2.42 +template = Template(open(options.template_file).read()) 2.43 outfile.write(template.render(vars()))