[Bioperl-l] Modify / Delete features from Bio::Seq object?
Brian Osborne
b_i_osborne@hotmail.com
Wed, 30 Jan 2002 15:21:32 -0500
Simon,
As I'm writing I'm looking at Bio::SeqFeature::Generic, where I see a new()
method used, as well as add_sub_SeqFeature() and flush_sub_SeqFeature(). As
I've never written anything using this module I won't claim any particular
understanding of it but I did notice that the script scripts/gff2ps.pl uses
some of these methods, perhaps it would help you. I will add a note to
bioperl.pod about this script, bioperl.pod should list all scripts and
examples....
Brian O.
----- Original Message -----
From: "simon andrews (BI)" <simon.andrews@bbsrc.ac.uk>
To: "Bioperl (E-mail)" <bioperl-l@bioperl.org>
Sent: Wednesday, January 30, 2002 4:45 AM
Subject: [Bioperl-l] Modify / Delete features from Bio::Seq object?
> I'm trying to put together a script which runs through and EMBL file and
> removes or modifies the features contained within it. I can parse through
> the features OK, and pick out those I need to deal with, but I can't find
> any methods which allow me to delete or modify existing features (only add
> new ones).
>
> I realise I could do this by creating a new sequence and selectively
copying
> features across, but as these sequences can be big I'd rather just modify
an
> existing one. Also, I couldn't find a new() method defined in
> Bio::SeqFeatureI. How do you create a new feature?
>
> In the code below, I'd like to delete each feature / tag whose name is
> currently printed. I've tried calling undef on those features (hoping
that
> they were references back to the Bio::RichSeq object), but this had no
> effect on the sequence written back out.
>
> Any help is greatly appreciated.
>
> Simon.
>
>
>
> #!/usr/bin/perl -w
> use strict;
> use Bio::SeqIO;
>
> my ($filein,$fileout) = @ARGV;
>
> unless ($fileout){die "Command line is convert [infile] [outfile]\n";}
>
> my $seqio_in = Bio::SeqIO -> new (-format => 'embl',
> -file => $filein);
>
> my $seqio_out = Bio::SeqIO -> new (-format => 'embl',
> -file => ">$fileout");
>
> die "Couldn't read $filein\n" unless ($seqio_in);
>
> my $inseq = $seqio_in -> next_seq();
>
> foreach my $feature ($inseq -> all_SeqFeatures()){
>
> my $tag = $feature -> primary_tag;
>
> if ($tag eq "exon" or $tag eq "prediction"){
>
> print "$tag\n"; # Need to remove these features
>
> }
>
> elsif ($tag eq 'CDS'){
>
>
> foreach my $alltag ($feature -> all_tags()){
>
> if ($alltag eq 'transcript' or $alltag eq 'cds'){
>
> print "\t$alltag\n"; # Need to remove these tags
>
> }
> }
> }
> }
>
> $seqio_out -> write_seq($inseq);
> _______________________________________________
> Bioperl-l mailing list
> Bioperl-l@bioperl.org
> http://bioperl.org/mailman/listinfo/bioperl-l
>