How To Modify Contig Format:
2
0
Entering edit mode
11.0 years ago
HG ★ 1.2k

Hi everyone I need co change a contig file format : can any one help me out using awk or perl

Input file:

>NODE_411_length_76_cov_325.381_ID_5152754
AAGAAGCAAATAtAAACAGCATTAAAGATATACACATAAAAATGAAGTACTAAA
>NODE_412_length_75_cov_54.1_ID_5146650
CCCTAAATTGAGAAAATAACTTTAGGGAATATATCAATGTACAGTGCCCGCTTCGTTAT
>NODE_413_length_74_cov_63.8947_ID_373286
GTATTGATCCAAAATCGGTGTAAATATTACCCTTTTTAGGTGTATTAGGTGTTAAATGTA

Out put should be like :

>Contig0.1
AAGAAGCAAATtAtAAACtAGCATTAAAGATATACACATAAAAATGAAGTACTAAA    
>Contig0.2
CCCTAAATTGAGAAAAaTAACTTTAGGGAATATATCAATGTACAGTGCCCGCTTCGTTAT
>Contig0.3
GTATTGATCCAAAATCGGTGTAAATATTACCCTTTTTAGGTGTATTAGGTGTTAAATGTA

Thank you advance .

perl awk fasta • 2.1k views
ADD COMMENT
0
Entering edit mode

Your output format is awkward, why would you want that? It's not even fasta format because of the extra whitespace before >. What do you need the extra line break for? Please be more specific about what you want to change, as your examples do not match each other.

ADD REPLY
0
Entering edit mode

Do you just need the names ("NODE_411...", etc.) changed or is something supposed to be done with the sequences as well? How are we to know what bases should be made lower case or is that already done? I have a feeling that you don't actually know what you would like to do (you're certainly not providing enough information for anyone to help you).

ADD REPLY
0
Entering edit mode

Hello, i have modify the above question please have a look.

ADD REPLY
3
Entering edit mode
11.0 years ago

Given the update:

awk 'BEGIN{i=1; OFS=""}{if(substr($0,1,1) == ">") { print ">Contig0.",i; i+=1}else{print $0}}' foo.fa
ADD COMMENT
1
Entering edit mode

Another awk option:

awk '{/^>/ && sub(/>.+/,">Contig0."++i); print}' foo.fa
ADD REPLY
0
Entering edit mode

Nice, that's rather more concise than mine!

ADD REPLY
0
Entering edit mode

Thank you so much . Its working fine.

ADD REPLY
2
Entering edit mode
11.0 years ago
Kenosis ★ 1.3k

With Perl:

perl -lne 's/^>.+/">Contig0.".++$i/e;print' foo.fa
ADD COMMENT

Login before adding your answer.

Traffic: 1551 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6