Package: samsum
samsumA light-weight python package for summarizing sequence coverage from SAM and BAM filesInstallationSamsum is currently supported on Mac and Linux systems and has been tested primarily on Ubuntu operating systems
(bionic and trusty distributions).
It is a python package on the Python Package Index (PyPI) and can be installed usingpip:pip install samsumSamsum can also be installed usingcondawith the command:condainstall-cbiocondasamsumYou can also install samsum from source by cloning the directory from its GitHub page or downloading a GitHub release.gitclonehttps://github.com/hallamlab/samsum.gitcdsamsum
python3setup.pysdist
pipinstalldist/samsum*tar.gzUsagesamsum statswill read either a SAM or BAM file (this functionality will be implemented soon) and
rapidly count the number of reads mapped to each reference sequence (e.g. contigs, scaffolds)
while also keeping track of the reads that remain unmapped.
This all occurs within the C++ Python extension.
It will then read the reference FASTA file to gather the lengths of each reference sequence.
Combining the read counts and sequence lengths, it will then calculate:fragments per kilobase per million (FPKM)transcripts per milllion (TPM)Command-line optionsBy default, reads with multiple identical alignments (i.e. mapping quality is 0) are not included in these calculations.
This can be toggled off to include these alignments with the--mflag.
Another option is to drop counts for reference sequences if only a portion of a sequence is mapped to.
With the-pargument, you can control the minimum proportion a reference sequence needs to be covered
for its read counts to be included in the output; all stats are otherwise set to 0.An example command is:samsumstats-fref.fasta-aalignments.sam--multireads-p0.5-ooutput_dir/samsum_table.tsvThis will include all alignments, regardless of their mapping quality but only report alignments for reference sequences
that were covered across at least 50% of their length.APIBeing a python package, samsum can also be readily imported into python code and used via its API.The function generally desired would beref_sequence_abundances. Usage could be:fromsamsumimportcommandssam="/home/user/reads_to_genome.sam"fasta="/home/user/genome.fasta"ref_seq_abunds=commands.ref_sequence_abundances(aln_file=sam,seq_file=fasta,min_aln=10,p_cov=0,map_qual=0)Theref_seq_abundsobject is a dictionary ofRefSequenceinstances indexed by their header/sequence names.RefSequenceobjects have several variables that are of interest:self.nameis the name of the (reference) sequence or headerself.lengthis the length (in base-pairs) of the sequenceself.reads_mappedis the number of reads that were mappedself.weight_totalis the number of fragments (float) that were mapped to the sequenceself.fpkmis Fragments Per Kilobase per Million mapped readsself.tpmis Transcripts Per Million mapped readsOutputsIfsamsum statswas executed, a "samsum_log.txt" file is written to the current working directory
(i.e. wheresamsumwas executed from). A comma-separated value (CSV) file with the fields
"QueryName", "RefSequence", "ProportionCovered", "Coverage", "Fragments", "FPKM" and "TPM" is written to a file
path specified on the command-line, or by default "samsum_table.csv".
A TSV file can be written instead if thesepargument was modified to 'tab'.