Bio::Tools::GFF [Re: [Bioperl-l] Bio::SeqFeature::Generic]
Jason Stajich
jason at cgt.duhs.duke.edu
Wed Oct 22 09:39:09 EDT 2003
I've got a fix - this code really needed to be written better. I'm using
arrays and joins instead of chop-ing strings post-hoc.
Index: Bio/Tools/GFF.pm
===================================================================
RCS file: /home/repository/bioperl/bioperl-live/Bio/Tools/GFF.pm,v
retrieving revision 1.29
diff -r1.29 GFF.pm
570c570
< my $valuestr;
---
>
571a572
> my @group;
573,575d573
< $str .= "\t"; # my interpretation of the GFF2
< # specification suggests the need
< # for this additional TAB character...??
577,579c575
< my $valuestr; # a string which will hold one or more values
< # for this tag, with quoted free text and
< # space-separated individual values.
---
> my @v;
585c581,582
< $value = '"' . $value . '" '} # if the value contains
---
> $value = '"' . $value . '" ';
> } # if the value contains
589c586
< $value = "\"\"" unless defined $value;
---
> $value = '\""' unless defined $value;
593,595c590,591
< $valuestr .= $value . " "; # with a trailing space in case
< # there are multiple values
< # for this tag (allowed in GFF2 and .ace format)
---
> push @v, $value;
> # for this tag (allowed in GFF2 and .ace format)
597c593
< $str .= "$tag $valuestr ; "; # semicolon delimited with no '='
sign
---
> push @group, "$tag ".join(" ", @v);
599d594
< chop $str; chop $str; # remove the trailing semicolon and space
600a596
> $str .= "\t" . join(' ; ', @group);
-jason
-jason
On Wed, 22 Oct 2003, Heikki Lehvaslaiho wrote:
> Charles,
>
> Your code should be fine.
>
> I can see the extra spaces in the output by running the
> following script as 'gfftest.pl |od'.
>
> The method that needs changing is Bio::Tools::GFF::_gff2_string(), I'd
> rather have feedback from GFF people first. Lincoln or someone from his
> group should be able to say what is the correct way to solve this
> problem.
>
> Yours,
> -Heikki
>
> ---------------------gfftest.pl--------------------------------
> use Bio::Tools::GFF;
> use Bio::SeqFeature::Generic;
> use Data::Dumper;
>
> my $gffout = Bio::Tools::GFF->new(-gff_version => 2);
>
> my $feat = new Bio::SeqFeature::Generic();
> $feat->seq_id('111');
> $feat->source_tag('assembly');
> $feat->primary_tag('contig');
> $feat->start('1');
> $feat->end(123);
> $feat->add_tag_value('Contig','111');
> $gffout->write_feature($feat);
> #print Dumper $feat;
> --------------------------------------------------------
>
> On Tue, 2003-10-21 at 18:37, Charles Hauser wrote:
> > Don't know if this is a bug or a problem on my end.
> >
> > Using Bio::SeqFeature::Generic to generate gff:
> >
> > my $feat = new Bio::SeqFeature::Generic();
> > $feat->seq_id($seq->id);
> > $feat->source_tag('assembly');
> > $feat->primary_tag('contig');
> > $feat->start('1');
> > $feat->end($seq->length);
> > $feat->add_tag_value('Contig',$seq->id);
> > $out->write_feature($feat);
> >
> > I end up with 2 extra spaces following the group tag ('Contig
> > scaffold_1') which results in gbrowse returning: ...landmark not
> > recognized...
> >
> > deleting these spaces makes all right with the world.
> >
> > Is the problem in my code or in Bio::SeqFeature::Generic?
> >
> > Charles
> >
> >
> > ______________________________________________________________________
> > _______________________________________________
> > Bioperl-l mailing list
> > Bioperl-l at portal.open-bio.org
> > http://portal.open-bio.org/mailman/listinfo/bioperl-l
>
--
Jason Stajich
Duke University
jason at cgt.mc.duke.edu
More information about the Bioperl-l
mailing list