bioruby-samtools icon indicating copy to clipboard operation
bioruby-samtools copied to clipboard

Writing alignments to file

Open gusevfe opened this issue 13 years ago • 3 comments

Is it possible to write alignments to file?

E.g. I want to process an existing .bam file by removing a part of the sequence. How do I do that?

gusevfe avatar Feb 15 '12 07:02 gusevfe

Hi, can you clarify what you require. I guess you want to process an alignment, removing some of the sequence, create a new Bio::DB::Alignment object and write that to a new BAM file? Or are you trying to do something more complicated?

cheers

danmaclean avatar Feb 16 '12 10:02 danmaclean

That's exactly what I want.

On Thu, Feb 16, 2012 at 2:13 PM, danmaclean < [email protected]

wrote:

Hi, can you clarify what you require. I guess you want to process an alignment, removing some of the sequence, create a new Bio::DB::Alignment object and write that to a new BAM file? Or are you trying to do something more complicated?

cheers


Reply to this email directly or view it on GitHub: https://github.com/helios/bioruby-samtools/issues/10#issuecomment-3998036

Kind regards, Fedor Gusev.

gusevfe avatar Feb 16 '12 10:02 gusevfe

The official samtools C API function for writing to BAM isn't implemented yet, as it is a bit complicated and we considered most users would want to use BAM as a datasource much more than as a sink. The workaround is to use the Bio::DB::Alignment#to_s method that writes the alignment object in SAM, which you can convert to BAM the old fashioned way. We are working on making BAM writable.

cheers

danmaclean avatar Feb 16 '12 15:02 danmaclean