Hi, I have a related task:
I have a tab-delimited list of primers of a known gene:
<name 1> <sequence 1>
<name 2> <sequence 2>
etc.
We know on which chromosome the gene is, of course.
I would like to run the entire list and get a BED file of the primer locations:
chr"n" Start Stop <name 1> 0 +or- Start Stop
chr"n" Start Stop <name 2> 0 +or- Start Stop
etc.
The BED file is used to show the primers on a custom annotation track in the Alamut program. I am looking for a way to do this with a batch of primers instead of copying and pasting them in a dialog box one by one. I tried BLAT but that requires primers of at least 20 nt length, which we don't always have.
Thank you!
Unconfigured Ad
Collapse
X
-
got it. Many thanks to Dario!Originally posted by dariober View PostIf you want to search both strands than do not use the --noreverse flag and for palindromic patterns, by definition, you will get the same position twice (on + and -). But it seems this is not what you wanted in your previous post.
You would have to convert your bam file to bed and pass it to intersectBed as the b-file with -c flag. This will count for each feature in the a-file the number of hits with the b-file. But why not to use coverageBed that it is designed for this purpose?
Dario
Leave a comment:
-
If you want to search both strands than do not use the --noreverse flag and for palindromic patterns, by definition, you will get the same position twice (on + and -). But it seems this is not what you wanted in your previous post.Originally posted by owwa View PostActually, I need to search both + and - strand for palindromic patterns. Could you please help again?
You would have to convert your bam file to bed and pass it to intersectBed as the b-file with -c flag. This will count for each feature in the a-file the number of hits with the b-file. But why not to use coverageBed that it is designed for this purpose?By the way, how about intersectBed for the read counts. Thanks!
Dario
Leave a comment:
-
Thank you so much Dario!Originally posted by dariober View PostHi- glad you made it work! So with palindromic patterns you want to search only one strand, right? You can use the --noreverse flag:
Type "fastaRegexFinder.py -h" to see the program's helpCode:echo ">ref1 NNNGCTTCTACTG >ref2 AGAAGCNNNN NNNCCGG" | fastaRegexFinder.py -f - -r 'CCGG' --noreverse ref2 13 17 ref2_13_17_for 4 + CCGG
By the way, if you want to count how many reads in your bam file overlap the positions of your "tag" you could use bedtools coverageBed:
DarioCode:fastaRegexFinder.py -f myseq.fa -r 'CCGG' --noreverse | coverageBed -abam myaln.bam -b - -counts > tag.count.bed
Actually, I need to search both + and - strand for palindromic patterns. Could you please help again?
By the way, how about intersectBed for the read counts. Thanks!Last edited by owwa; 07-04-2013, 04:53 PM.
Leave a comment:
-
Hi- glad you made it work! So with palindromic patterns you want to search only one strand, right? You can use the --noreverse flag:Originally posted by owwa View PostThe script works well. Thanks!
if there is a fix for palindromic sequence, it will be better! for example, when I use the palindromic sequence tag CCGG, it return repeated records:
CL1.Contig1_243 size 1223 gap 0 0% 311 315 CL1.Contig1_243 size 1223 gap 0 0%_311_315_for 4 + CCGG
CL1.Contig1_243 size 1223 gap 0 0% 311 315 CL1.Contig1_243 size 1223 gap 0 0%_311_315_rev 4 - CCGG
CL1.Contig1_243 size 1223 gap 0 0% 1056 1060 CL1.Contig1_243 size 1223 gap 0 0%_1056_1060_for 4 + CCGG
CL1.Contig1_243 size 1223 gap 0 0% 1056 1060 CL1.Contig1_243 size 1223 gap 0 0%_1056_1060_rev 4 - CCGG
CL1.Contig2_243 size 879 gap 0 0% 311 315 CL1.Contig2_243 size 879 gap 0 0%_311_315_for 4 + CCGG
CL1.Contig2_243 size 879 gap 0 0% 311 315 CL1.Contig2_243 size 879 gap 0 0%_311_315_rev 4 - CCGG
CL2.Contig1_243 size 1389 gap 0 0% 513 517 CL2.Contig1_243 size 1389 gap 0 0%_513_517_for 4 + CCGG
CL2.Contig1_243 size 1389 gap 0 0% 513 517 CL2.Contig1_243 size 1389 gap 0 0%_513_517_rev 4 - CCGG
CL2.Contig1_243 size 1389 gap 0 0% 622 626 CL2.Contig1_243 size 1389 gap 0 0%_622_626_for 4 + CCGG
CL2.Contig1_243 size 1389 gap 0 0% 622 626 CL2.Contig1_243 size 1389 gap 0 0%_622_626_rev 4 - CCGG
CL2.Contig1_243 size 1389 gap 0 0% 867 871 CL2.Contig1_243 size 1389 gap 0 0%_867_871_for 4 + CCGG
CL2.Contig1_243 size 1389 gap 0 0% 867 871 CL2.Contig1_243 size 1389 gap 0 0%_867_871_rev 4 - CCGG
CL2.Contig1_243 size 1389 gap 0 0% 874 878 CL2.Contig1_243 size 1389 gap 0 0%_874_878_for 4 + CCGG
CL2.Contig1_243 size 1389 gap 0 0% 874 878 CL2.Contig1_243 size 1389 gap 0 0%_874_878_rev 4 - CCGG
Type "fastaRegexFinder.py -h" to see the program's helpCode:echo ">ref1 NNNGCTTCTACTG >ref2 AGAAGCNNNN NNNCCGG" | fastaRegexFinder.py -f - -r 'CCGG' --noreverse ref2 13 17 ref2_13_17_for 4 + CCGG
By the way, if you want to count how many reads in your bam file overlap the positions of your "tag" you could use bedtools coverageBed:
DarioCode:fastaRegexFinder.py -f myseq.fa -r 'CCGG' --noreverse | coverageBed -abam myaln.bam -b - -counts > tag.count.bed
Last edited by dariober; 07-04-2013, 12:08 AM.
Leave a comment:
-
The script works well. Thanks!Originally posted by dariober View PostHello,
I'm not sure why you mention the bam file... If you want to get the position of a pattern in a fasta file I happen to write a while ago a simple python script (attached) which searches a fasta file for a regular expression and returns the position of the matches in bed format. (You need python2.7 or any python with argparse module)
After unzipping fastaRegexFinder.py.gz you would do:
It's not superfast as it is pure pyhton but it should suite most needs. In fact, if you don't care searching for regular expressions you could use some general aligner tools like vmatch.Code:## Default: Search tag on forward and reverse strand, case insensitive python fastaRegexFinder.py -r 'GCTTCT' -f reference.fasta ref1 3 9 ref1_3_9_for 6 + GCTTCT ref2 0 6 ref2_0_6_rev 6 - AGAAGC ## Where example.fasta looks like: cat example.fasta >ref1 NNNGCTTCTACTG >ref2 AGAAGCNNNN
Dario
if there is a fix for palindromic sequence, it will be better! for example, when I use the palindromic sequence tag CCGG, it return repeated records:
CL1.Contig1_243 size 1223 gap 0 0% 311 315 CL1.Contig1_243 size 1223 gap 0 0%_311_315_for 4 + CCGG
CL1.Contig1_243 size 1223 gap 0 0% 311 315 CL1.Contig1_243 size 1223 gap 0 0%_311_315_rev 4 - CCGG
CL1.Contig1_243 size 1223 gap 0 0% 1056 1060 CL1.Contig1_243 size 1223 gap 0 0%_1056_1060_for 4 + CCGG
CL1.Contig1_243 size 1223 gap 0 0% 1056 1060 CL1.Contig1_243 size 1223 gap 0 0%_1056_1060_rev 4 - CCGG
CL1.Contig2_243 size 879 gap 0 0% 311 315 CL1.Contig2_243 size 879 gap 0 0%_311_315_for 4 + CCGG
CL1.Contig2_243 size 879 gap 0 0% 311 315 CL1.Contig2_243 size 879 gap 0 0%_311_315_rev 4 - CCGG
CL2.Contig1_243 size 1389 gap 0 0% 513 517 CL2.Contig1_243 size 1389 gap 0 0%_513_517_for 4 + CCGG
CL2.Contig1_243 size 1389 gap 0 0% 513 517 CL2.Contig1_243 size 1389 gap 0 0%_513_517_rev 4 - CCGG
CL2.Contig1_243 size 1389 gap 0 0% 622 626 CL2.Contig1_243 size 1389 gap 0 0%_622_626_for 4 + CCGG
CL2.Contig1_243 size 1389 gap 0 0% 622 626 CL2.Contig1_243 size 1389 gap 0 0%_622_626_rev 4 - CCGG
CL2.Contig1_243 size 1389 gap 0 0% 867 871 CL2.Contig1_243 size 1389 gap 0 0%_867_871_for 4 + CCGG
CL2.Contig1_243 size 1389 gap 0 0% 867 871 CL2.Contig1_243 size 1389 gap 0 0%_867_871_rev 4 - CCGG
CL2.Contig1_243 size 1389 gap 0 0% 874 878 CL2.Contig1_243 size 1389 gap 0 0%_874_878_for 4 + CCGG
CL2.Contig1_243 size 1389 gap 0 0% 874 878 CL2.Contig1_243 size 1389 gap 0 0%_874_878_rev 4 - CCGGLast edited by owwa; 07-03-2013, 11:40 PM.
Leave a comment:
-
Hi Dario,Originally posted by dariober View PostHello,
I'm not sure why you mention the bam file... If you want to get the position of a pattern in a fasta file I happen to write a while ago a simple python script (attached) which searches a fasta file for a regular expression and returns the position of the matches in bed format. (You need python2.7 or any python with argparse module)
After unzipping fastaRegexFinder.py.gz you would do:
It's not superfast as it is pure pyhton but it should suite most needs. In fact, if you don't care searching for regular expressions you could use some general aligner tools like vmatch.Code:## Default: Search tag on forward and reverse strand, case insensitive python fastaRegexFinder.py -r 'GCTTCT' -f reference.fasta ref1 3 9 ref1_3_9_for 6 + GCTTCT ref2 0 6 ref2_0_6_rev 6 - AGAAGC ## Where example.fasta looks like: cat example.fasta >ref1 NNNGCTTCTACTG >ref2 AGAAGCNNNN
Dario
thank you so much for your kind help! iI will try it.
I just want to extract the read count from the BAM file for the position where has the tag GCTTCT or some other tags,Last edited by owwa; 07-03-2013, 04:42 AM.
Leave a comment:
-
Hello,Originally posted by owwa View PostI have a BAM file and also the related refference genome (fasta), and now I need to extract all the position for some tags, such as "GCTTCT" in the genome, and then make a custom bed file for these tags as the following:
chr1 127471196 127472363 +
chr1 127472363 127473530 +
chr1 127473530 127474697 +
chrx 127474697 127475864 +
chr2 127475864 127477031 -
chr3 127477031 127478198 -
chr5 127478198 127479365 -
chr7 127479365 127480532 +
chr7 127480532 127481699 -
Your help will be greatly appreciated!
I'm not sure why you mention the bam file... If you want to get the position of a pattern in a fasta file I happen to write a while ago a simple python script (attached) which searches a fasta file for a regular expression and returns the position of the matches in bed format. (You need python2.7 or any python with argparse module)
After unzipping fastaRegexFinder.py.gz you would do:
It's not superfast as it is pure pyhton but it should suite most needs. In fact, if you don't care searching for regular expressions you could use some general aligner tools like vmatch.Code:## Default: Search tag on forward and reverse strand, case insensitive python fastaRegexFinder.py -r 'GCTTCT' -f reference.fasta ref1 3 9 ref1_3_9_for 6 + GCTTCT ref2 0 6 ref2_0_6_rev 6 - AGAAGC ## Where example.fasta looks like: cat example.fasta >ref1 NNNGCTTCTACTG >ref2 AGAAGCNNNN
DarioAttached Files
Leave a comment:
-
how to create a custom bed file
I have a BAM file and also the related refference genome (fasta), and now I need to extract all the position for some tags, such as "GCTTCT" in the genome, and then make a custom bed file for these tags as the following:
chr1 127471196 127472363 +
chr1 127472363 127473530 +
chr1 127473530 127474697 +
chrx 127474697 127475864 +
chr2 127475864 127477031 -
chr3 127477031 127478198 -
chr5 127478198 127479365 -
chr7 127479365 127480532 +
chr7 127480532 127481699 -
Your help will be greatly appreciated!Tags: None
Latest Articles
Collapse
-
by SEQadmin2
When the Human Genome Project declared the human genome finished in 2003, portions of the sequence were still missing, including many of its most repetitive and structurally complex regions.1 Still, for the next two decades, researchers analyzed their sequencing data against the single linear reference that came out of this effort. Released in 2013 as GRCh38, that reference has powered countless discoveries, but it has gaps and cannot capture the genetic diversity of the world’s...-
Channel: Articles
11-24-2026, 07:04 AM -
ad_right_rmr
Collapse
News
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by SEQadmin2, Today, 11:10 AM
|
0 responses
11 views
0 reactions
|
Last Post
by SEQadmin2
Today, 11:10 AM
|
||
|
Single-Nucleus Sequencing Links Type 2 Diabetes Risk Variants to Specific Muscle Cell Types
by SEQadmin2
Started by SEQadmin2, Yesterday, 11:06 AM
|
0 responses
20 views
0 reactions
|
Last Post
by SEQadmin2
Yesterday, 11:06 AM
|
||
|
Started by SEQadmin2, 11-23-2026, 11:11 AM
|
0 responses
58 views
0 reactions
|
Last Post
by SEQadmin2
11-23-2026, 11:11 AM
|
||
|
Started by SEQadmin2, 11-17-2026, 06:27 AM
|
0 responses
55 views
0 reactions
|
Last Post
by SEQadmin2
11-17-2026, 06:27 AM
|
Leave a comment: