Python list comprehension enables for easy manipulation of a list variable. For example, list comprehension can be used to convert from a string to an integer or float as well as do some common operation on a list. Below is an example script that shows the syntax for list comprehension and how to utilize the code in Python. Hope its helpful.
A repository of programs, scripts, and tips essential to
genetic epidemiology, statistical genetics, and bioinformatics
Welcome to the Genome Toolbox! I am glad you navigated to the blog and hope you find the contents useful and insightful for your genomic needs. If you find any of the entries particularly helpful, be sure to click the +1 button on the bottom of the post and share with your colleagues. Your input is encouraged, so if you have comments or are aware of more efficient tools not included in a post, I would love to hear from you. Enjoy your time browsing through the Toolbox.
Showing posts with label sort. Show all posts
Showing posts with label sort. Show all posts
Monday, August 25, 2014
Wednesday, July 23, 2014
Sort BAM File in Samtools
Samtools does a host of useful operations for .bam files. One such operation is sorting. Below is a simple example script to show how to use samtools to sort an unsorted BAM file.
This script will sort the unsorted.bam using 8 threads that allocates 12G of memory per thread. The resulting sorted .bam file will be called sorted.bam.
To confirm a .bam file is sorted, check the header (samtools view -H sorted.bam) for the line:
SO:coordinate.
Additionally, here is the usage information for Samtools sort:
Usage: samtools sort [options]
Options: -n sort by read name
-f use as full file name instead of prefix
-o final output to stdout
-l INT compression level, from 0 to 9 [-1]
-@ INT number of sorting and compression threads [1]
-m INT max memory per thread; suffix K/M/G recognized [768M]
This script will sort the unsorted.bam using 8 threads that allocates 12G of memory per thread. The resulting sorted .bam file will be called sorted.bam.
To confirm a .bam file is sorted, check the header (samtools view -H sorted.bam) for the line:
SO:coordinate.
Additionally, here is the usage information for Samtools sort:
Usage: samtools sort [options]
Options: -n sort by read name
-f use
-o final output to stdout
-l INT compression level, from 0 to 9 [-1]
-@ INT number of sorting and compression threads [1]
-m INT max memory per thread; suffix K/M/G recognized [768M]
Wednesday, May 29, 2013
Unix Sort by Column Number
I always forget the flags to use when using UNIX sort. Here is a list of common useful flags.
Flags
-k: selects the column number to sort
-n: indicates you are sorting numeric values so use numeric ordering (ex: 10, 11, not 10, 100)
-r: sort in reverse (descending) order for this column
An example line of code that sorts by numeric values in column 2 in descending order would be as follows.
Subscribe to:
Posts (Atom)