Unconfigured Ad
Collapse
X
-
GenoMax, you probably mean to call the output file "outfile.fastq", right?Originally posted by GenoMax View PostA command line solution. See if this works:
Code:$ samtools view -h file.bam | awk -F'\t' '{OFS = "\n"; ORS = "\n";}{ if ($3 == "*" ) print "@"$1,$10,"+",$11}' > outfile.bam
Code:$ samtools view -h file.bam | awk -F'\t' '{OFS = "\n"; ORS = "\n";}{ if ($3 == "*" ) print "@"$1,$10,"+",$11}' > outfile.[B]fastq[/B]
Leave a comment:
-
Just write a quick little script in python with pysam to do this. There isn't always a premade program to do everything.
Leave a comment:
-
All I want is the Unmapped reads with no mate or an unmapped mate are assigned to chrom "*" , not include unmapped mate reads which assigned to chr1, chr2, ...
just reads assigned to
"*" 0 0 42640654
Leave a comment:
-
Are you asking about why the number is not adding up to 42640654? See possible explanation here: https://www.biostars.org/p/18949/Last edited by GenoMax; 02-10-2015, 07:05 PM.
Leave a comment:
-
I tried the parameter: -f 4Originally posted by GenoMax View Post
And then index the result bam file
Here is the idxstats from it:
chrM 16571 0 32042
chr1 249250621 0 1937746
chr2 243199373 0 2244387
chr3 198022430 0 1501432
chr4 191154276 0 1825761
chr5 180915260 0 1486923
chr6 171115067 0 1273600
chr7 159138663 0 1531851
chr8 146364022 0 1315785
chr9 141213431 0 1184324
chr10 135534747 0 2018103
chr11 135006516 0 1373030
chr12 133851895 0 1180836
chr13 115169878 0 616704
chr14 107349540 0 758336
chr15 102531392 0 624791
chr16 90354753 0 991456
chr17 81195210 0 916042
chr18 78077248 0 1614444
chr19 59128983 0 755016
chr20 63025520 0 644231
chr21 48129895 0 547857
chr22 51304566 0 277926
chrX 155270560 0 1365662
chrY 59373566 0 642042
* 0 0 42640654
Any suggestions ?
Leave a comment:
-
https://www.biostars.org/p/56246/Originally posted by jjlaisnoopy View PostThis is good method to split bam file. But I got a question.
* 0 0 42640654
How could I get the "*" 42640654 reads, those were not mapped to any contigs ?
Leave a comment:
-
This is good method to split bam file. But I got a question.
The following is idxstats of a bam file:
chrM 16571 2073252 32042
chr1 249250621 115733016 1937746
chr2 243199373 104133908 2244387
chr3 198022430 96577573 1501432
chr4 191154276 89582368 1825761
chr5 180915260 94818025 1486923
chr6 171115067 84533173 1273600
chr7 159138663 71186849 1531851
chr8 146364022 65630236 1315785
chr9 141213431 59368028 1184324
chr10 135534747 63503839 2018103
chr11 135006516 59963670 1373030
chr12 133851895 63898721 1180836
chr13 115169878 41939790 616704
chr14 107349540 43647215 758336
chr15 102531392 39227879 624791
chr16 90354753 42298502 991456
chr17 81195210 49043800 916042
chr18 78077248 75701725 1614444
chr19 59128983 26119207 755016
chr20 63025520 32668117 644231
chr21 48129895 19226969 547857
chr22 51304566 15797809 277926
chrX 155270560 74715396 1365662
chrY 59373566 2021162 642042
* 0 0 42640654
How could I get the "*" 42640654 reads, those were not mapped to any contigs ?
Leave a comment:
-
Thanks everyone. I will give these suggestions a try and let you know how it went.
Leave a comment:
-
Watch out, you don't want the first ("@HD ...") nor the last ("@PG ...") line of the header.Originally posted by vivek_ View PostThat's why you have the BAM index right, so you are not reading the entire file to export each coordinate?
for the sequentiality issue, you can extract the contig names from the bam header into a file and loop over them:
Code:samtools view -H input.bam | awk '{print $2}' | awk '{gsub(/SN\:/,""); print}' > contigs.txt
Try this instead:
Or, if you prefer awk:Code:samtools view -H all.bam | sed '1d;s/.*SN:\(.*\)\t.*/\1/;$d' > contigs.list
or even (just for fun):Code:samtools view -H all.bam | awk '/^@SQ/{gsub(/SN\:/,"");print $2}' > contigs.list
All those should give you the same list of contigs.Code:samtools idxstats all.bam | cut -f1 > contigs.list
Then,
But I agree it might take a while...Code:for c in `cat contigs.list` ; do echo processing $c samtools view -bh all.bam $c > $c.bam done
Leave a comment:
-
That's why you have the BAM index right, so you are not reading the entire file to export each coordinate?
for the sequentiality issue, you can extract the contig names from the bam header into a file and loop over them:
Code:samtools view -H input.bam | awk '{print $2}' | awk '{gsub(/SN\:/,""); print}' > contigs.txt
Leave a comment:
-
Depends, I've seen examples where the contigs weren't sequentially numbered (presumably due to some contigs becoming merged as latter data came in)Originally posted by vivek_ View PostA unix oneliner should work right?
Code:for i in {1..22};do samtools view -bh input.bam chr$i > chr$i.bam;done
Also, for a file with a large number of contigs (have a look at some of the mouse lines from the Sanger Institute), looping over the whole file many many times will get super slow. You could probably write a script to process the whole thing in one go in a fraction of the time.
Leave a comment:
Latest Articles
Collapse
-
by SEQadmin2
Tumors contain complex mixtures of cell populations that evolve in response to treatment and host-specific factors. Tissue biopsies provide only static snapshots of a tumor’s state. But what if we could follow that evolution over time using a minimally invasive technique?
Liquid biopsies can detect tumor-derived material circulating in the bloodstream, providing a way to study treatment response, detect emerging resistance, and discover new biomarkers. Circulating...-
Channel: Articles
10-14-2026, 09:55 AM -
-
by SEQadmin2
Researchers using sequencing and genomics tools often have to make trade-offs. They can choose between speed or scale, short reads or long-range information, or targeted panels or a view of the whole transcriptome. New technologies that have been released this year are built to address those tough choices.
We asked six companies the same four questions to learn about their latest products. The new technologies bring a lot to the table, including rethinking sequencing...-
Channel: Articles
-
ad_right_rmr
Collapse
News
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by SEQadmin2, 10-22-2026, 11:13 AM
|
0 responses
53 views
0 reactions
|
Last Post
by SEQadmin2
10-22-2026, 11:13 AM
|
||
|
Started by SEQadmin2, 10-22-2026, 10:48 AM
|
0 responses
39 views
0 reactions
|
Last Post
by SEQadmin2
10-22-2026, 10:48 AM
|
||
|
Started by SEQadmin2, 10-15-2026, 10:52 AM
|
0 responses
46 views
0 reactions
|
Last Post
by SEQadmin2
10-15-2026, 10:52 AM
|
||
|
Started by SEQadmin2, 10-14-2026, 05:39 AM
|
0 responses
46 views
0 reactions
|
Last Post
by SEQadmin2
10-14-2026, 05:39 AM
|
Leave a comment: