Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Removing deprecated Martel dependent module Bio.NBRF

  • Loading branch information...
commit 585ac9c0326031273a8eec061a82cf745694e08e 1 parent 986a399
@peterjc peterjc authored
View
78 Bio/NBRF/Record.py
@@ -1,78 +0,0 @@
-# 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 based parser to read NBRF formatted files.
-
-This is a huge regular regular expression for NBRF, built using
-the 'regular expressiona on steroids' capabilities of Martel.
-
-http://www-nbrf.georgetown.edu/pirwww/pirhome.shtml
-
-
-Notes:
-Just so I remember -- the new end of line syntax is:
- New regexp syntax - \R
- \R means "\n|\r\n?"
- [\R] means "[\n\r]"
-
-This helps us have endlines be consistent across platforms.
-
-"""
-
-
-from Bio.Seq import Seq
-from Bio.NBRF.ValSeq import valid_sequence_dict
-
-
-
-"""Hold NBRF data in a straightforward format.
-
-classes:
-o Record - All of the information in an NBRF record.
-"""
-
-class Record:
- """Hold NBRF information in a format similar to the original record.
-
- The Record class is meant to make data easy to get to when you are
- just interested in looking at NBRF data.
-
- Attributes:
- sequence_type
- sequence_name
- comment
- sequence
-
- """
- def __init__(self):
- self.sequence_type = ''
- self.sequence_name = ''
- self.comment = ''
- self.sequence = Seq('')
-
- def __str__( self ):
- sequence_type = valid_sequence_dict[ self.sequence_type ]
- output = 'Sequence type %s\n' % sequence_type
- output = output + 'Sequence name %s\n' % self.sequence_name
- output = output + '%s\n' % self.comment
- output = output + out_sequence( self.sequence.data )
- return output
-
-def out_sequence( seq ):
- output = ''
- for j in range( 0, len( seq ), 80 ):
- output = output + '%s\n' % seq[ j: j + 80 ]
- output = output + '\n'
- return output
-
-
-
-
-
-
-
-
-
-
View
4 Bio/NBRF/ValSeq.py
@@ -1,4 +0,0 @@
-valid_sequence_dict = { "P1": "complete protein", "F1": "protein fragment", \
- "DL": "linear DNA", "DC": "circular DNA", "RL": "linear RNA", \
- "RC":"circular RNA", "N3": "transfer RNA", "N1": "other"
- }
View
149 Bio/NBRF/__init__.py
@@ -1,149 +0,0 @@
-# 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.
-"""Parser for the NBRF/PIR file format (DEPRECATED).
-
-Please use Bio.SeqIO with the "pir" format instead."""
-
-import warnings
-warnings.warn("Bio.NBRF is deprecated." \
- + " We hope the new 'pir' format support in Bio.SeqIO will be" \
- + " suitable for most users. Please get in touch on the " \
- + " mailing lists if this (or its removal) causes any problems "\
- + "for you.",
- DeprecationWarning)
-
-
-# Martel
-import Martel
-from Martel import RecordReader
-
-from Bio.ParserSupport import EventGenerator
-from Bio import File
-import nbrf_format
-import Record
-
-class Iterator:
- """Iterator interface to move over a file of NBRF entries one at a time.
- """
- def __init__(self, handle, parser = None):
- """Initialize the iterator.
-
- Arguments:
- o handle - A handle with NBRF entries to iterate through.
- o parser - An optional parser to pass the entries through before
- returning them. If None, then the raw entry will be returned.
- """
- self.handle = File.UndoHandle( handle )
- self._reader = RecordReader.StartsWith( self.handle, ">" )
- self._parser = parser
-
- def next(self):
- """Return the next NBRF record from the handle.
-
- Will return None if we ran out of records.
- """
- data = self._reader.next()
-
- if self._parser is not None:
- if data:
- return self._parser.parse(File.StringHandle(data))
-
- return data
-
- def __iter__(self):
- return iter(self.next, None)
-
-class _Scanner:
- """Start up Martel to do the scanning of the file.
-
- This initialzes the Martel based parser and connects it to a handler
- that will generate events for a Feature Consumer.
- """
- def __init__(self, debug = 0):
- """Initialize the scanner by setting up our caches.
-
- Creating the parser takes a long time, so we want to cache it
- to reduce parsing time.
-
- Arguments:
- o debug - The level of debugging that the parser should
- display. Level 0 is no debugging, Level 2 displays the most
- debugging info (but is much slower). See Martel documentation
- for more info on this.
- """
- # a listing of all tags we are interested in scanning for
- # in the MartelParser
- self.interest_tags = [ "sequence_type", \
- "sequence_name", \
- "comment", \
- "sequence_line", \
- "sequence_final_text" ]
-
- # make a parser that returns only the tags we are interested in
- expression = Martel.select_names( nbrf_format.nbrf_record, self.interest_tags)
- self._parser = expression.make_parser(debug_level = debug)
-
- def feed(self, handle, consumer):
- """Feeed a set of data into the scanner.
-
- Arguments:
- o handle - A handle with the information to parse.
- o consumer - The consumer that should be informed of events.
- """
- self._parser.setContentHandler( EventGenerator(consumer,
- self.interest_tags))
-# self._parser.setErrorHandler(handle.ErrorHandler())
-
- self._parser.parseFile(handle)
-
-class _RecordConsumer:
- """Create an NBRF Record object from scanner generated information.
- """
- def __init__(self):
- self.data = Record.Record()
- self._sequences = []
-
- def sequence_type(self, sequence_type ):
- self.data.sequence_type = "".join(sequence_type)
-
- def sequence_name(self, sequence_name ):
- self.data.sequence_name = "".join(sequence_name)
-
- def comment(self, comment ):
- self.data.comment = "".join(comment)
-
- def sequence_line( self, sequences ):
- new_seq = "".join(sequences)
- parts = new_seq.split()
- self._sequences.append("".join(parts))
-
- def sequence_final_text( self, sequences ):
- new_seq = "".join(sequences)
- parts = new_seq.split()
- self._sequences.append("".join(parts))
-
- self.data.sequence.data = "".join(self._sequences)
-
-class RecordParser:
- """Parse NBRF files into Record objects
- """
- def __init__(self, debug_level = 0):
- """Initialize the parser.
-
- Arguments:
- o debug_level - An optional argument that specifies the amount of
- debugging information Martel should spit out. By default we have
- no debugging info (the fastest way to do things), but if you want
- you can set this as high as two and see exactly where a parse fails.
- """
- self._scanner = _Scanner(debug_level)
-
- def parse(self, handle):
- """Parse the specified handle into an NBRF record.
- """
- self._consumer = _RecordConsumer()
- self._scanner.feed(handle, self._consumer)
- return self._consumer.data
-
View
52 Bio/NBRF/nbrf_format.py
@@ -1,52 +0,0 @@
-# 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 based parser to read NBRF formatted files.
-
-This is a huge regular regular expression for NBRF, built using
-the 'regular expressiona on steroids' capabilities of Martel.
-
-http://www-nbrf.georgetown.edu/pirwww/pirhome.shtml
-"""
-
-# Martel
-import Martel
-from Martel import Str
-from Martel import AnyEol, UntilEol
-from Martel import Group
-from Martel import Alt
-from Martel import Rep
-from Martel import Rep1
-from Martel import AnyBut
-from Martel import UntilSep
-
-from Bio.NBRF.ValSeq import valid_sequence_dict
-
-sequence_types = map( Str, valid_sequence_dict.keys() )
-sequence_type = Group( "sequence_type", Alt( *sequence_types ) )
-name_line = Martel.Group( "name_line", \
- Str( ">" ) +
- sequence_type +
- Str( ";" ) +
- UntilEol("sequence_name") +
- AnyEol() )
-
-comment_line = UntilEol("comment") + AnyEol()
-
-# 0x2a -- '*'
-# 10 -- '\n', 13 -- '\r' newline endings
-excluded_chars = chr(0x2a) + chr(10) + chr(13)
-# sequence lines with only sequence
-sequence_text = Group( "sequence_text", \
- Martel.Rep1( AnyBut( excluded_chars ) ) )
-sequence_line = Group( "sequence_line", sequence_text +
- AnyEol())
-# the final line, has a '*' and potentially some sequence
-sequence_final_line = Group( "sequence_final_line",
- UntilSep("sequence_final_text", chr(0x2a)) + Str(chr(0x2a)) +
- Rep1(AnyEol()))
-
-sequence_block = Group("sequence_block", Rep( sequence_line ))
-nbrf_record = name_line + comment_line + sequence_block + sequence_final_line
View
4 DEPRECATED
@@ -116,7 +116,6 @@ Bio.Sequencing.Ace.Iterator --> Bio.Sequencing.Ace.parse(handle)
Bio.Sequencing.Phd.RecordParser --> Bio.Sequencing.Phd.read(handle)
Bio.Sequencing.Phd.Iterator --> Bio.Sequencing.Phd.parse(handle)
-
Bio.Blast.NCBIWWW
=================
The HTML BLAST parser was deprecated as of Release 1.48.
@@ -129,7 +128,8 @@ on Martel which doesn't work properly with mxTextTools 3.0.
Bio.NBRF
========
-Deprecated as of Release 1.48 in favor of the "pir" format in Bio.SeqIO
+Deprecated as of Release 1.48 in favor of the "pir" format in Bio.SeqIO,
+removed in Release 1.51.
Bio.IntelliGenetics
===================
Please sign in to comment.
Something went wrong with that request. Please try again.