Logo Search packages:      
Sourcecode: python-biopython version File versions

def Bio::expressions::genbank::define_block (   identifier,
  block_tag,
  block_data,
  std_block_tag = None,
  std_tag = None 
)

Define a Martel grouping which can parse a block of text.

Many of the GenBank lines we'll want to process are grouped into
a block like:

IDENTIFIER   Blah blah blah

Where blah blah blah can wrap for multiple lines. This function makes
it easy to consistently define a definition for these blocks.

Arguments:
o identifier - The identifier that begins the block (like DEFINITION).
o block_tag - A callback tag for the entire block.
o block_data - A callback tag for the data in the block (ie. the
stuff you are interested in).
o std_block_tag - A Bio.Std Martel tag used to register the entire
block as having being a "standard" type of information.
o std_tag - A Bio.Std Martel tag used to register just the information
in the block as being "standard"

Definition at line 36 of file genbank.py.

                                :
    """Define a Martel grouping which can parse a block of text.

    Many of the GenBank lines we'll want to process are grouped into
    a block like:

    IDENTIFIER   Blah blah blah

    Where blah blah blah can wrap for multiple lines. This function makes
    it easy to consistently define a definition for these blocks.

    Arguments:
    o identifier - The identifier that begins the block (like DEFINITION).
    o block_tag - A callback tag for the entire block.
    o block_data - A callback tag for the data in the block (ie. the
    stuff you are interested in).
    o std_block_tag - A Bio.Std Martel tag used to register the entire
    block as having being a "standard" type of information.
    o std_tag - A Bio.Std Martel tag used to register just the information
    in the block as being "standard"
    """
    diff = INDENT - len(identifier)
    assert diff > 0, diff
   
    # if no std_tag info is defined, just make std_tag a no-op function
    if std_tag is None:
        def do_nothing(martel_info):
            return martel_info
        std_tag = do_nothing

    identifier_and_text = Martel.Str(identifier) + \
                          Martel.Rep(Martel.Str(" ")) + \
                          std_tag(Martel.UntilEol(block_data)) + \
                          Martel.AnyEol()
    indented_text = Martel.Str(" "*INDENT) + \
                    std_tag(Martel.UntilEol(block_data)) + \
                    Martel.AnyEol()
    block_info = Martel.Group(
        block_tag,
        identifier_and_text +
        Martel.Rep(Martel.Alt(Martel.AnyEol(), indented_text))
        )
    # tag the info as some standard Martel element if specified
    if std_block_tag is not None:
        block_info = std_block_tag(block_info)

    return block_info


# first line
# LOCUS       AC007323    86436 bp    DNA             PLN       19-JAN-2000
locus = Martel.Group("locus",


Generated by  Doxygen 1.6.0   Back to index