import pysam
tabixfile = pysam.Tabixfile( "/usr/local/xyz.vcf" )
And now when I'm doing this:
row = tabixfile.fetch(reference='chr1', start=249240539, end=249240539)
but while doing
x = row[2]
I am getting this error.
Where I am going wrong actually? Any pointers?
• 0 views
•
link
Could you be more specific? Do you want to fetch only certain columns from a subset of rows, or do you just want certain columns from the whole data?
Use awk on pysam output for exact column.
If the OP is using pysam, it's a good guess that they are already in a Python environment. awk, while extremely useful, is a worse fit than simply accessing the AlignedRead object returned by the IteratorRow object returned by Samfile.fetch().
I am specifically working with TSV files. So, I here is an example of TSV file:
When I use fetch to get row for chr 1 and pos 2399, I get the following:
1\t2399\tTrueHowever, I want a way to directly access judgement value for chr 1 and pos 2399. I'd like to directly call the exact column value. I cannot use awk. I was wondering if there is a direct way of doing so using Pysam. Thank you for all your help.