def test_ToEol(): parser = Martel.ToEol("SantaFe").make_parser() parseString = parser.parseString must_parse("ToEol", parseString, "Testing, 1, 2, 3!\n") must_parse("ToEol", parseString, "Andrew\n") must_not_parse("ToEol", parseString, "Dalke") must_not_parse("ToEol", parseString, "This\nis") must_not_parse("ToEol", parseString, "This\nis a test\n") file = StringIO.StringIO() parser.setContentHandler(saxutils.XMLGenerator(file)) parser.parseString("This is a test.\n") s = file.getvalue() expect = "<SantaFe>This is a test.</SantaFe>\n" assert string.find(s, expect) != -1, ("Got: %s" % (repr(s), ))
"""Martel definitions for the output files produced by primer3. """ import Martel any_space = Martel.Re("[ ]+") blank_line = Martel.AnyEol() comment_line = Martel.Str("#") + Martel.ToEol() # comments and blank lines in the file comments = Martel.Group("comments", blank_line + comment_line + blank_line + comment_line) # 1 PRODUCT SIZE: 289 product_size = Martel.Group("product_size", Martel.Re("[\d]+")) start_primer = Martel.Group( "start_primer", any_space + Martel.Re("[\d]+") + Martel.Str(" PRODUCT SIZE: ")) primer_start_line = Martel.Group("primer_start_line", start_primer + product_size + Martel.AnyEol()) # a blank line that signifies a new primer is coming up single_primer_line = Martel.Group("single_primer_line", blank_line) # FORWARD PRIMER 1725 20 59.96 55.00 AGGGAAGGGATGCTAGGTGT primer_space = Martel.Str(" " * 5) any_integer = Martel.Re("[\d]+") any_float = Martel.Re("[\d\.]+") sequence = Martel.Re("[GATCN]+")
RN + \ RP + \ Martel.Opt(RC_block) + \ Martel.Opt(RX) + \ RA_block + \ Martel.Opt(RT_block) + \ RL_block ) ############ #--- CC CC_begin = Martel.Group("CC", Martel.Re("CC -!- ") + \ Martel.ToEol("comment_text")) CC = Martel.Group("CC", Martel.Re("CC ") + \ Martel.ToEol("comment_text")) single_comment = Martel.Group("comment", CC_begin + Martel.Rep(CC)) CC_copyright_begin = Martel.Group("CC_copyright_begin", Martel.Re("CC -+\R")) CC_copyright = Martel.Group("CC_copyright", Martel.Re("CC (?!-+\R)") + \ Martel.ToEol("copyright")) CC_copyright_end = Martel.Group("CC_copyright_end", Martel.Re("CC -+\R")) # From N33_HUMAN bogus_DR_group = Martel.Group("bogus_DR_block", Martel.Re(r"(?P<DR>DR (?P<database_identifier>MIM); " \
# Copyright 2001 by Katharine Lindner. All rights reserved. # This code is part of the Biopython distribution and governed by its # license. Please see the LICENSE file that should have been included # as part of this package. """Martel regular expression for Intelligenetic format (DEPRECATED). This is a huge regular regular expression for the IntelliGenetics/MASE format, built using the 'regular expressions on steroids' capabilities of Martel. """ #http://immuno.bme.nwu.edu/seqhunt.html # Martel import Martel # --- first set up some helper constants and functions comment_line = Martel.Group( "comment_line", \ Martel.Str( ';' ) + Martel.ToEol( "comment" ) ) comment_lines = Martel.Group("comment_lines", Martel.Rep(comment_line)) title_line = Martel.Group( "title_line", \ Martel.Expression.Assert( Martel.Str( ';' ), 1 ) + Martel.ToEol() ) residue_line = Martel.Group( "residue_line", \ Martel.Expression.Assert( Martel.Str( ';' ), 1 ) + Martel.ToEol( "sequence" ) ) residue_lines = Martel.Group("residue_lines", Martel.Rep1(residue_line)) intelligenetics_record = comment_lines + title_line + residue_lines
"""Martel format for primersearch output files, """ import Martel blank_line = Martel.AnyEol() # Primer name D1S2660 primer_name = Martel.Group("primer_name", Martel.ToEol()) primer_name_line = Martel.Str("Primer name ") + primer_name # Amplimer 1 amplifier = Martel.Group("amplifier", Martel.Re("[\d]+")) amplimer_line = Martel.Str("Amplimer ") + amplifier + Martel.AnyEol() # Sequence: AC074298 AC074298 # Telomere associated sequence for Arabidopsis thaliana TEL1N # CCGGTTTCTCTGGTTGAAAA hits forward strand at 114 with 0 mismatches # TCACATTCCCAAATGTAGATCG hits reverse strand at [114] with 0 mismatches seq_indent = Martel.Str("\t") sequence_id = Martel.Group("sequence_id", Martel.ToEol()) sequence_descr = Martel.Group("sequence_descr", Martel.ToEol()) sequence_info = sequence_id + sequence_descr forward_strand_info = Martel.Group("forward_strand_info", Martel.ToEol()) reverse_strand_info = Martel.Group("reverse_strand_info", Martel.ToEol()) amplifier_sequence = Martel.Group( "amplifier_sequence", sequence_info + forward_strand_info + reverse_strand_info) amplifier_sequence_lines = seq_indent + Martel.Str("Sequence: ") + \ amplifier_sequence