Parsing a fasta sequence with start and end coordinates


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Parsing a fasta sequence with start and end coordinates
# 1  
Old 04-15-2011
Parsing a fasta sequence with start and end coordinates

Hi.. I have a seperate chromosome sequences and i wanted to parse some regions of chromosome based on start site and end site.. how can i achieve this?

For Example Chr 1 is in following format

Quote:
>chr1
GAATTCCAAAGCCAAAGATTGCATCAGTTCTGCTGCTATTTCCTCCTATCATTCTTTCTGATGTTGAAAATGATATTAAG
I need regions from 2 - 10 should give me AATTCCAAA

and in a similar way 15- 25 should give me AAGATTGCAT

and from 27 - 30 should give me AGTT

How can i do it either in perl or bioperl or awk or any other way?

Last edited by empyrean; 04-15-2011 at 02:55 AM..
# 2  
Old 04-15-2011
Code:
awk -v start=2 -v end=10 -v chr=chr1 '$0~chr{getline seq; print substr(seq,start,end-start+1)}' sequence
AATTCCAAA

awk -v start=15 -v end=25 -v chr=chr1 '$0~chr{getline seq; print substr(seq,start,end-start+1)}' sequence
AAGATTGCATC

# 3  
Old 04-15-2011
Thanks for the reply.. i am pretty new to awk programming.. so i have chromosome 1 in a fasta file format and where should i give it as input?
# 4  
Old 04-15-2011
Using cut command
Code:
cut -c2-10 inputfile

# 5  
Old 04-15-2011
cut command is not working properly.. its splicing whole file in to 10 frament length lines
# 6  
Old 04-15-2011
Quote:
Originally Posted by empyrean
Thanks for the reply.. i am pretty new to awk programming.. so i have chromosome 1 in a fasta file format and where should i give it as input?
I think it should be ok if you use the whole fasta file as the input file:
Code:
awk '{CODE}' fasta

# 7  
Old 04-15-2011
No its not giving correct results.. I have the fasta file of 300,000 bp long.. but i need the sequences for some specific sites.. The above code in awk only giving the sequence of one line no matter how much length you give.. Also if the start site is after the first line, we are not getting any information about it..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Splitting week start date and end date based on custom period start dates

Below are my custom period start and end dates based on a calender, these dates are placed in a file, for each period i need to split into three weeks for each period row, example is given below. Could you please help out to achieve solution through shell script.. File content: ... (2 Replies)
Discussion started by: nani2019
2 Replies

2. UNIX for Beginners Questions & Answers

How to find a specific sequence pattern in a fasta file?

I have to mine the following sequence pattern from a large fasta file namely gene.fasta (contains multiple fasta sequences) along with the flanking sequences of 5 bases at starting position and ending position, AAGCZ-N16-AAGCZ Z represents A, C or G (Except T) N16 represents any of the four... (3 Replies)
Discussion started by: dineshkumarsrk
3 Replies

3. Shell Programming and Scripting

Command Line Perl for parsing fasta file

I would like to take a fasta file formated like >0001 agttcgaggtcagaatt >0002 agttcgag >0003 ggtaacctga and use command line perl to move the all sample gt 8 in length to a new file. the result would be >0001 agttcgaggtcagaatt >0003 ggtaacctga cat ${sample}.fasta | perl -lane... (2 Replies)
Discussion started by: jdilts
2 Replies

4. Shell Programming and Scripting

Parsing and masking regions from a single fasta file with subsequence

HI, I have a Complete genome fasta file and I have list of sub sequence regions in the format as : 4353..5633 6795..9354 1034..14456 I want a script which can mask these region in a single complete genome fasta file with the alphabet N kindly help (2 Replies)
Discussion started by: margarita
2 Replies

5. Shell Programming and Scripting

Count and search by sequence in multiple fasta file

Hello, I have 10 fasta files with sequenced reads information with read sizes from 15 - 35 . I have combined the reads and collapsed in to unique reads and filtered for sizes 18 - 26 bp long unique reads. Now i wanted to count each unique read appearance in all the fasta files and make a table... (5 Replies)
Discussion started by: empyrean
5 Replies

6. Shell Programming and Scripting

Extract sequence from fasta file

Hi, I want to match the sequence id (sub-string of line starting with '>' and extract the information upto next '>' line ). Please help . input > fefrwefrwef X900 AGAGGGAATTGG AGGGGCCTGGAG GGTTCTCTTC > fefrwefrwef X932 AGAGGGAATTGG AGGAGGTGGAG GGTTCTCTTC > fefrwefrwef X937... (2 Replies)
Discussion started by: ritakadm
2 Replies

7. UNIX for Dummies Questions & Answers

Change sequence names in fasta file

I have fasta files with multiple sequences in each. I need to change the sequence name headers from: >accD:_59176-60699 ATGGAAAAGTGGAGGATTTATTCGTTTCAGAAGGAGTTCGAACGCA >atpA_(reverse_strand):_showing_revcomp_of_10525-12048 ATGGTAACCATTCAAGCCGACGAAATTAGTAATCTTATCCGGGAAC... (2 Replies)
Discussion started by: tyrianthinae
2 Replies

8. Shell Programming and Scripting

Remove lines between the start string and end string including start and end string Python

Hi, I am trying to remove lines once a string is found till another string is found including the start string and end string. I want to basically grab all the lines starting with color (closing bracket). PS: The line after the closing bracket for color could be anything (currently 'more').... (1 Reply)
Discussion started by: Dabheeruz
1 Replies

9. UNIX for Dummies Questions & Answers

How to change sequence name in along fasta file?

Hi I have an alignment file (.fasta) with ~80 sequences. They look like this- >JV101.contig00066(+):25302-42404|sequence_index=0|block_index=4|species=JV101|JV101_4_0 GAGGTTAATTATCGATAACGTTTAATTAAAGTGTTTAGGTGTCATAATTT TAAATGACGATTTCTCATTACCATACACCTAAATTATCATCAATCTGAAT... (2 Replies)
Discussion started by: baika
2 Replies

10. UNIX for Dummies Questions & Answers

Help Parsing Sequence File

Hi Everyone, I am new in the world of UNIX and Shell scripting. I am working with a sequence file that looks like this: >contig00001 length=128 numreads=2 aTGTGCTGGgTGGGTGCCTGTTgCCccATGCTCCAGTtCAGGATTtCAGGCAttCTCATG TCCAGCATTTCTATTTAATCCTGCTGCTGGACTTGGGTGGtCTCAGTCtGGGAAGTGAGC tGTCTGTG... (8 Replies)
Discussion started by: Fahmida
8 Replies
Login or Register to Ask a Question