chapmanb / bcbb

Incubator for useful bioinformatics code, primarily in Python and R
http://bcbio.wordpress.com
604 stars 243 forks source link

GFF parsing with initial sequence fails #75

Closed benjiec closed 10 years ago

benjiec commented 10 years ago

Hi Brad,

I tried to use the GFF parser with initial sequence. I followed the example from the Wiki, and essentially had something like

  def import_sequence_and_gff(self, fasta_fn, gff_fn):
    in_seq_file = fasta_fn
    in_seq_handle = open(fasta_fn)
    seq_dict = SeqIO.to_dict(SeqIO.parse(in_seq_handle, "fasta"))
    in_seq_handle.close()

    in_file = gff_fn
    in_handle = open(in_file)
    for rec in GFF.parse(in_handle, base_dict=seq_dict):
      print rec
      in_handle.close()

But I get this error message

ValueError: Only CompoundLocation gets an operator ('join')

Looking through the stack, it looks like GFF created a SeqFeature with a SeqLocation, and tried to use the 'join' operator, and BioPython only allows CompoundLocation to have operators.

I am not familiar with the details of BioPython and GFF parser, is this a known problem? Is there a work-around?

Thanks, Benjie

chapmanb commented 10 years ago

Benjie; Thanks for the problem report. I hadn't fixed the feature location handling in the GFF parser to handle the new CompoundLocations in 1.62. For now I updated a solution that will handle both 1.62 and previous versions, so if you upgrade the GFF parser to 0.3 it should work cleanly. Please let me know if you run into any more issues and thanks again.

benjiec commented 10 years ago

Brad,

Thanks for the fix. I can confirm that 0.3 works for my test case (reading yeast GFF fro SGD).

Thanks, Benjie

On Wed, Sep 18, 2013 at 10:57 AM, Brad Chapman notifications@github.comwrote:

Benjie; Thanks for the problem report. I hadn't fixed the feature location handling in the GFF parser to handle the new CompoundLocations in 1.62. For now I updated a solution that will handle both 1.62 and previous versions, so if you upgrade the GFF parser to 0.3 it should work cleanly. Please let me know if you run into any more issues and thanks again.

— Reply to this email directly or view it on GitHubhttps://github.com/chapmanb/bcbb/issues/75#issuecomment-24670594 .