This is a test version of Biostars. For the public version, visit https://www.biostars.org.
How Do I Generate Nucleotides Present Either Per Site or One I Choose?

I'm quite new in the world of bioinformatics and am self learning (no science degree). As the title of the post asks, how do I generate a list of every nucleotide that is present at any one given site? (a range would be great too) I'm looking for results similar to how IGV represents each site when you click on coverage.

My current commands are

bcftools mpileup -Ou -f SARS-CoV-2_reference.fasta {accession}.sorted.bam | bcftools call -mv -Ob -o {accession}.bcf
bcftools query -f  '{accession} %REF%POS%ALT\n'  {accession}.bcf

Thank you for your help!

bcftools mpileup

2 answers

In case someone is here in the future and wants the same output I have found a python script that does exactly what I needed.

allelecount

have a look at sam2tsv : http://lindenb.github.io/jvarkit/Sam2Tsv.html

samtools view -O BAM indexed.bam "chr1:234-235" | java -jar dist/sam2tsv -R ref.fasta

Thank you Pierre! I just tried it and i get this

samtools view SRR11409417.sorted.bam "NC_045512.2:29090-29096" | java -jar JavaKit/jvarkit/dist/sam2tsv.jar -R SARS-CoV-2_reference.fasta

[SEVERE][MultiBamLauncher]Dictionary missing : A Sequence dictionary is missing for <bam>. A Bam should have a header with a set of lines starting with '@SQ' see https://samtools.github.io/hts-specs/SAMv1.pdf com.github.lindenb.jvarkit.lang.JvarkitException$BamDictionaryMissing: Dictionary missing : A Sequence dictionary is missing for <bam>. A Bam should have a header with a set of lines starting with '@SQ' see https://samtools.github.io/hts-specs/SAMv1.pdf at com.github.lindenb.jvarkit.util.bio.SequenceDictionaryUtils.extractRequired(SequenceDictionaryUtils.java:166) at com.github.lindenb.jvarkit.jcommander.MultiBamLauncher.doWork(MultiBamLauncher.java:242) at com.github.lindenb.jvarkit.util.jcommander.Launcher.instanceMain(Launcher.java:796) at com.github.lindenb.jvarkit.util.jcommander.Launcher.instanceMainWithExit(Launcher.java:959) at com.github.lindenb.jvarkit.tools.sam2tsv.Sam2Tsv.main(Sam2Tsv.java:441) [INFO][Launcher]sam2tsv Exited with failure (-1)

samtools view SRR11409417.sorted.bam "NC_045512.2:29090-29096"

this is not the command I wrote.

sorry I thought the O was a 0 so the command wasn't working :/ apologies

Log in to answer this question.