Can I Get An All Uppercase Dna Sequence From Bio::Seq Without Uc?
2
2
Entering edit mode
14.2 years ago
Flies ▴ 100

I've got a lot of perl code that expects DNA sequences to be uppercase strings. I want to use Bio::SeqIO for reading them in, but Bio::Seq method seq() returns a lowercase string. uc doesn't really take all that long, but it would be nice if I didn't have to use it since I'm reading in whole chromosomes here.

perl bioperl • 4.4k views
ADD COMMENT
4
Entering edit mode
14.2 years ago

It retains the case that went in:

e.g

keith@tao:~$ cat convert.pl

#!/usr/bin/perl

use strict;
use warnings;

use Bio::SeqIO;

my $iformat = shift;
my $oformat = shift;

$iformat ||= 'fasta';
$oformat ||= 'fasta';

my $seqi = Bio::SeqIO->new(-fh     => \*STDIN,
                           -format => $iformat);
my $seqo = Bio::SeqIO->new(-fh     => \*STDOUT,
                           -format => $oformat);

while (my $seq = $seqi->next_seq) {
    $seqo->write_seq($seq);
}

keith@tao:~$ cat foo.fasta 
>foo
AGTCGACGTAGTCACGTGTCA

keith@tao:~$ convert.pl < foo.fasta
>foo
AGTCGACGTAGTCACGTGTCA

keith@tao:~$ cat bar.fasta 
>bar
agtcgacgtagtcacgtgtca

keith@tao:~$ converter.pl < bar.fasta
>bar
agtcgacgtagtcacgtgtca
ADD COMMENT
2
Entering edit mode
14.2 years ago
Heikki ▴ 360

The design principle of Bio::Seq objects is that the case of the sequence should not matter. If it does, you have to code it yourself.

ADD COMMENT

Login before adding your answer.

Traffic: 2781 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6