Moving sequence in to next line in multi fasta file
1
0
Entering edit mode
5.0 years ago

This question might be repetitive, however I am not able to find a solution for me. I am quite new to bioinformatics I have a multi fasta file with several sequences, like this as shown below in the example. I want to move my sequence(s) in the next line after the header. I have tried couple of commands but could not get the desired output.

Lymphocytic_choriomeningitis_mammarenavirus 1653394 11623 Lymphocytic_choriomeningitis_mammarenavirus None NP AATTTCCCCGGCCCGGG

Desired output

Lymphocytic_choriomeningitis_mammarenavirus 1653394 11623 Lymphocytic_choriomeningitis_mammarenavirus None NP
AATTTCCCCGGCCCGGG

Any help is much appreciated.

sequencing • 1.3k views
ADD COMMENT
0
Entering edit mode

You need to add a new line character \n explicitly. Which programming language you are using? Provide your code to answer your question perfectly.

ADD REPLY
0
Entering edit mode
5.0 years ago

You can try something like this; however, I would do some rigorous checking of the output.

cat test 
Lymphocytic_choriomeningitis_mammarenavirus 1653394 11623
Lymphocytic_choriomeningitis_mammarenavirus None NP AATTTCCCCGGCCCGGG
Lymphocytic_choriomeningitis_mammar
Lymphocytic_NP AATTTCCCCGGCCCGGG
Lymphocytic_choriomeningitis_mammarenavirus 1653394 11623 hello hhhh
Lymphocytic AATTTCCCCGGCCCGGG
Lymphocytic_choriomeningitis_mammarenavirus 1653394
test ATGC

awk -F " " '!/[[:space:]][ATGC]*$/{printf $0" "}; /[[:space:]][ATGC]*$/{for (i=1; i<NF; i++) {printf $(i)" "} print "\n"$(NF)}' test

Lymphocytic_choriomeningitis_mammarenavirus 1653394 11623 Lymphocytic_choriomeningitis_mammarenavirus None NP 
AATTTCCCCGGCCCGGG
Lymphocytic_choriomeningitis_mammar Lymphocytic_NP 
AATTTCCCCGGCCCGGG
Lymphocytic_choriomeningitis_mammarenavirus 1653394 11623 hello hhhh Lymphocytic 
AATTTCCCCGGCCCGGG
Lymphocytic_choriomeningitis_mammarenavirus 1653394 test 
ATGC

This, in its current state, will not function as expected if a sequence (ATGC) is already the only entry on any given line.

Kevin

ADD COMMENT

Login before adding your answer.

Traffic: 1605 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