[Bioperl-l] nexus to fasta converter

Jason Stajich jason at cgt.mc.duke.edu
Mon Jan 27 15:37:23 EST 2003


>From the documentation for Bio::AlignIO::nexus

Title   : next_aln
 Usage   : $aln = $stream->next_aln()
 Function: Returns the next alignment in the stream.

           Supports the following NEXUS format features:
           - The file has to start with '#NEXUS'
           - Reads in the name of the alignment from a comment
             (anything after 'TITLE: ') .
           - Sequence names can be given in a taxa block, too.
           - If matchchar notation is used, converts
             them back to sequence characters.
           - Does character conversions specified in the
             NEXUS equate command.
           - Sequence names of type 'Homo sapiens' and
             Homo_sapiens are treated identically.


Perhaps if you'd be willing to post the file we can diagnose the problem
more effectively though.

Feel free to replace the sequence data with XX if you don't want to post
the actual sequences.

Also the file in bioperl-live/t/data/testaln.nexus provides an example of
what the parser theoretically supports.


-jason


On Mon, 27 Jan 2003, Amit R Indap wrote:

> Hi,
>
> I am trying to write a nexus to fasta file converter. I was looking at
> the AlignIO documentation and went from there. My problem is that my
> program never enters the while loop. As far as I know, nexus is one
> of the formats supported by AlignIO. Could it be that I have a
> non-standard nexus file?
>
> #!/usr/bin/perl
> use Bio::AlignIO;
> $file = "APX.nex";
> $stream = Bio::AlignIO->new(-file => $file, '-format' => 'nexus');
> $out = Bio::AlignIO->new(-file => ">out.aln.fasta" , '-format' =>
> 'fasta');
>
> while ( my $aln = $stream->next_aln() ) {
>     print "testing\n"; # never gets here
>     $out->write_aln($aln);
> }
>
> ---------------------------
>
> Amit Indap
> indapa at cs.arizona.edu
>
> I dunno, I dream in Perl sometimes...
>                         --Larry Wall in  <8538 at jpl-devvax.JPL.NASA.GOV>
>
> _______________________________________________
> Bioperl-l mailing list
> Bioperl-l at bioperl.org
> http://bioperl.org/mailman/listinfo/bioperl-l
>

--
Jason Stajich
Duke University
jason at cgt.mc.duke.edu


More information about the Bioperl-l mailing list