[Bioperl-l] create Bio::AlignIO object from hash

Roy Chaudhuri roy.chaudhuri at gmail.com
Mon Jan 11 13:54:25 UTC 2010


Actually, I guess some sample code would be more helpful:

use Bio::LocatableSeq;
use Bio::SimpleAlign;
use Bio::AlignIO;
my $seq1=Bio::LocatableSeq->new(-id=>'one', -seq=>'AT-CG', -start=>1, 
-end=>4);
my $seq2=Bio::LocatableSeq->new(-id=>'two', -seq=>'A--CG', -start=>1, 
-end=>3);
my $seq3=Bio::LocatableSeq->new(-id=>'three', -seq=>'ATTCG', -start=>1, 
-end=>5);
my $aln=Bio::SimpleAlign->new(-seqs=>[$seq1,$seq2,$seq3]);
Bio::AlignIO->new(-format=>'phylip')->write_aln($aln);

Cheers,
Roy.


On 11/01/2010 13:40, Roy Chaudhuri wrote:
> Hi Adam,
>
> I'm guessing you actually want to create a Bio::SimpleAlign object
> (representing an alignment), rather than a Bio::AlignIO object (which is
> just for reading/writing alignment files). Bio::SimpleAlign has a
> documented new method that allows you to construct an alignment from
> Bio::LocatableSeq objects, which are similar to Bio::Seq objects but
> include gaps and start/end coordinates to describe their relationship to
> other sequences in the alignment.
>
> Roy.
>
> On 11/01/2010 12:21, Adam Witney wrote:
>> Hi,
>>
>> I am writing a script to automate the running of Phylip Pars. In the
>> process i have to create a Bio::AlignIO object from a set of data
>> that i have in a hash.
>>
>> I could write the hash data into a phylip file and then load the
>> Bio::AlignIO from that file, but i wondered if i could skip the
>> writing and then reading of a temporary file ?
>>
>> thanks for any help
>>
>> adam _______________________________________________ Bioperl-l
>> mailing list Bioperl-l at lists.open-bio.org
>> http://lists.open-bio.org/mailman/listinfo/bioperl-l
>




More information about the Bioperl-l mailing list