This is a test version of Biostars. For the public version, visit https://www.biostars.org.
analyzing a read mapped file with python

hii.. I have a file containing reads aligned to the reference genome in fasta format. I want to identify the read-aligned position in the reference genome through python. is there any module that can read this kind of file and return me the aligned positions??

alignment python reads

You probably have a bam file. If you want a python module you can look at pysam.

thanks for the reply. but I do not have a bam file. I have a fasta file. I have attached a screenshot. I want to find out the position where the reads aligned to the reference genome. reads aligned to the reference

This is not in fasta format.

if you can post an example of the file, we can help you better

thanks for the reply, actually, it's an aligned file. I am unable to upload the file here so adding a screenshot of the file enter image description here

SeqIO or AlignIO from Biopython can help you in parsing fasta files. In your case, it looks like all you need to do is count the number of '-' characters before the sequence to determine the mapping position.
I should note that this is rather an unusual format for storing such data, so maybe you should reconsider the procedure that produced this file.

1 answer

I think you have gone the route of multiple sequence alignment, which is commonly used for gene or protein sequences. Did you use eg muscle or clustalomega for your (global) alignments ?

If using a reference genome, you should be aiming for local alignments. Use well known tools such as bwa mem for mapping versus a ref genome, and aim for BAM files, which give you the alignment position. There are many good tutorials for this.

thank you for your reply. now I am trying with BWA. but can I directly use BWA through python?? or do I have to use the locally installed one ???

Log in to answer this question.