I have just begun exploring Lincoln Stein's excellent Bio::DB::Bam perl module and have an elementary question. Is it possible to edit values of an Bio::DB::Bam::Alignment alignment object?
Here is a dead simple script that just copies a bam file.
my $bam = Bio::DB::Bam->open("in.bam") ;
my $fix = Bio::DB::Bam->open("out.bam", "w" ) ;
my $header = $bam->header();
$fix->header_write($header);
while (my $align = $bam->read1 ) {
# EDIT BAM FIELDS HERE
$fix->write1($align);
}
What I want to do is edit some of the fields before writing them. For example, for each alignment, I can access the CIGAR field with
$align->cigar_str
or $align->cigar_array
and I can get the sequence of the read with $align->qseq
-- but is there a way I can change these values before writing them to the new file?
I read through the CPAN documentation. At a first glance it does not look like there are setter methods? Have you tried giving an argument to the method call. $align->cigar_str(your string)?
Thank you, your hunch was quite right, no setter methods for most of the objects.