[BioPython] BioPython and Zope.
Cymon Cox
cymon at duke.edu
Tue Apr 20 11:06:07 EDT 2004
Hi Cristian,
When you add an External Method to your Zope application you assign it
directly to a function contained in a module. I don't think the imports
at the module level are never made.
In short try:
def SequenceRead(SequenceString):
import StringIO
from Bio import SeqRecord
from Bio import FASTA
input = StringIO.StringIO(SequenceString)
reader = FASTA.FastaReader(input) # Error line
seq = reader.next()
etc...
Cheers, Cymon
On Mon, 2004-04-19 at 17:28, Cristian S. Rocha wrote:
> Hello everybody,
>
> I'm trying to parse fasta string input using Zope. I made a Zope
> external method to interface with BioPython modules. This method work
> fine on command line, but It don't work in Zope.
>
> The code is:
>
> ----------------
> import StringIO
> from Bio import SeqRecord
> from Bio.SeqIO import FASTA
>
> def SequenceRead(SequenceString):
> input = StringIO.StringIO(SequenceString)
> reader = FASTA.FastaReader(input) # Error line
> seq = reader.next()
> while seq:
> print "> %s" % seq.id
> seq = reader.next()
> return "!"
>
> if __name__ == "__main__":
> print BioTools(
> """>123
> ATAGGGGATGATAGGAT
> >456
> GGATGAGGAGCGATGCG
> """
> )
> ----------------
>
> The error is:
>
> AttributeError: 'module' object has no attribute 'FastaReader'
>
> The traceback is:
>
> """
> Traceback (innermost last):
> Module ZPublisher.Publish, line 98, in publish
> Module ZPublisher.mapply, line 88, in mapply
> Module ZPublisher.Publish, line 39, in call_object
> Module OFS.DTMLMethod, line 127, in __call__
> Module DocumentTemplate.DT_String, line 474, in __call__
> Module DocumentTemplate.DT_Try, line 140, in render
> Module DocumentTemplate.DT_Try, line 183, in render_try_except
> Module DocumentTemplate.DT_Util, line 201, in eval
> - __traceback_info__: SequenceText
> Module <string>, line 1, in <expression>
> Module Shared.DC.Scripts.Bindings, line 306, in __call__
> Module Shared.DC.Scripts.Bindings, line 343, in _bindAndExec
> Module Products.PythonScripts.PythonScript, line 307, in _exec
> Module None, line 15, in Translate
> - <PythonScript at /biodb/TranslateSequence/Translate>
> - Line 15
> Module Products.ExternalMethod.ExternalMethod, line 224, in __call__
> - __traceback_info__: (('> Input.\r\nATGATGA\r\n> Output\r\nATGGGGAT',), {}, None)
> Module /usr/lib/zope/Extensions/BioTools.py, line 9, in SequenceRead
> AttributeError: 'module' object has no attribute 'FastaReader'
> """
>
> Do you have any idea why it's happening?
>
> Thanks,
> Cristian.
--
Cymon Cox <cymon at duke.edu>
Duke University
More information about the BioPython
mailing list