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

Adam Witney awitney at sgul.ac.uk
Mon Jan 11 11:27:15 EST 2010

Ah excellent, thanks Roy. I was indeed thinking about it the wrong way.

In the process of writing this i have created a 

Bio::Tools::Run::Phylo::Phylip::Pars class

which is essentially just a modified copy of ProtPars. I have also fixed a few typos and possible bugs in


I am of course happy to send these back in to the project... how would i best do this?



On 11 Jan 2010, at 13:54, Roy Chaudhuri wrote:

> 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