This is a test version of Biostars. For the public version, visit https://www.biostars.org.
EC file parsing

Dear all

I have some issue with the below data:

ENTRY       EC 1.1.1.35                 Enzyme
NAME        3-hydroxyacyl-CoA dehydrogenase;
            beta-hydroxyacyl dehydrogenase;
            beta-keto-reductase;
            3-keto reductase;
            3-hydroxyacyl coenzyme A dehydrogenase;
            beta-hydroxyacyl-coenzyme A synthetase;
            beta-hydroxyacylcoenzyme A dehydrogenase;
            beta-hydroxybutyrylcoenzyme A dehydrogenase;
            3-hydroxyacetyl-coenzyme A dehydrogenase;
            L-3-hydroxyacyl coenzyme A dehydrogenase;
            L-3-hydroxyacyl CoA dehydrogenase;
            beta-hydroxyacyl CoA dehydrogenase;
            3beta-hydroxyacyl coenzyme A dehydrogenase;
            3-hydroxybutyryl-CoA dehydrogenase;
            beta-ketoacyl-CoA reductase;
            beta-hydroxy acid dehydrogenase;
            3-L-hydroxyacyl-CoA dehydrogenase;
            3-hydroxyisobutyryl-CoA dehydrogenase;
            1-specific DPN-linked beta-hydroxybutyric dehydrogenase
CLASS       Oxidoreductases;
            Acting on the CH-OH group of donors;
            With NAD+ or NADP+ as acceptor

How can I parse all the multi-line entries of this file like ENTRY, NAME, and CLASS with multi-line entries mentioned above?

bash shell

I added markup to your post for increased readability. You can do this by selecting the text and clicking the 101010 button. When you compose or edit a post that button is in your toolbar, see image below:

101010 Button

Please give an example of the desired output.

Eh? I didn't propose a solution. I think you reacted on the wrong comment.

 grep  -E '^(ENTRY|NAME|CLASS)'  input.txt | cut -c 10- | paste - - -

It prints only single line output..I need multi-line output.

@OP: Please post expected output.

ENTRY            NAME             CLASS
EC 1.1.1.35   3-hydroxyacyl-CoA dehydrogenase;          Oxidoreductases;
            Acting on the CH-OH group of donors;
            With NAD+ or NADP+ as acceptor
            beta-hydroxyacyl dehydrogenase;
            beta-keto-reductase;
            3-keto reductase;
            3-hydroxyacyl coenzyme A dehydrogenase;
            beta-hydroxyacyl-coenzyme A synthetase;
            beta-hydroxyacylcoenzyme A dehydrogenase;
            beta-hydroxybutyrylcoenzyme A dehydrogenase;
            3-hydroxyacetyl-coenzyme A dehydrogenase;
            L-3-hydroxyacyl coenzyme A dehydrogenase;
            L-3-hydroxyacyl CoA dehydrogenase;
            beta-hydroxyacyl CoA dehydrogenase;
            3beta-hydroxyacyl coenzyme A dehydrogenase;
            3-hydroxybutyryl-CoA dehydrogenase;
            beta-ketoacyl-CoA reductase;
            beta-hydroxy acid dehydrogenase;
            3-L-hydroxyacyl-CoA dehydrogenase;
            3-hydroxyisobutyryl-CoA dehydrogenase;
            1-specific DPN-linked beta-hydroxybutyric d

Again, I added markup to your post for increased readability. You can do this by selecting the text and clicking the 101010 button. When you compose or edit a post that button is in your toolbar, see image below:

101010 Button

ENTRY            NAME             CLASS
EC 1.1.1.35   3-hydroxyacyl-CoA dehydrogenase;          Oxidoreductases;Acting on the CH-OH group of donors;
        With NAD+ or NADP+ as acceptor
            Acting on the CH-OH group of donors;
            With NAD+ or NADP+ as acceptor
            beta-hydroxyacyl dehydrogenase;
            beta-keto-reductase;
            3-keto reductase;
            3-hydroxyacyl coenzyme A dehydrogenase;
            beta-hydroxyacyl-coenzyme A synthetase;
            beta-hydroxyacylcoenzyme A dehydrogenase;
            beta-hydroxybutyrylcoenzyme A dehydrogenase;
            3-hydroxyacetyl-coenzyme A dehydrogenase;
            L-3-hydroxyacyl coenzyme A dehydrogenase;
            L-3-hydroxyacyl CoA dehydrogenase;
            beta-hydroxyacyl CoA dehydrogenase;
            3beta-hydroxyacyl coenzyme A dehydrogenase;
            3-hydroxybutyryl-CoA dehydrogenase;
            beta-ketoacyl-CoA reductase;
            beta-hydroxy acid dehydrogenase;
            3-L-hydroxyacyl-CoA dehydrogenase;
            3-hydroxyisobutyryl-CoA dehydrogenase;
            1-specific DPN-linked beta-hydroxybutyric d

2 answers

Code (this code would not print enzyme in first column i.e Entry column):

$  awk -F "  " '{if ($1=="") {$1=prev} prev=$1};{gsub("   +","\t")}1' test.txt |  datamash -g 1 collapse 2| datamash transpose  > test2.txt

output:

ENTRY   NAME    CLASS
EC 1.1.1.35 3-hydroxyacyl-CoA dehydrogenase;,beta-hydroxyacyl dehydrogenase;,beta-keto-reductase;,3-keto reductase;,3-hydroxyacyl coenzyme A dehydrogenase;,beta-hydroxyacyl-coenzyme A synthetase;,beta-hydroxyacylcoenzyme A dehydrogenase;,beta-hydroxybutyrylcoenzyme A dehydrogenase;,3-hydroxyacetyl-coenzyme A dehydrogenase;,L-3-hydroxyacyl coenzyme A dehydrogenase;,L-3-hydroxyacyl CoA dehydrogenase;,beta-hydroxyacyl CoA dehydrogenase;,3beta-hydroxyacyl coenzyme A dehydrogenase;,3-hydroxybutyryl-CoA dehydrogenase;,beta-ketoacyl-CoA reductase;,beta-hydroxy acid dehydrogenase;,3-L-hydroxyacyl-CoA dehydrogenase;,3-hydroxyisobutyryl-CoA dehydrogenase;,1-specific DPN-linked beta-hydroxybutyric dehydrogenase   Oxidoreductases;,Acting on the CH-OH group of donors;,With NAD+ or NADP+ as acceptor

If you don't mind enzyme in first column, then the code is:

$ awk -F "  " '{if ($1=="") {$1=prev} prev=$1}1' test.txt   | awk '{$1=$1; sub(" ","\t")}1' |  datamash -g1 collapse 2 | datamash transpose

input:

$ cat test.txt 
ENTRY       EC 1.1.1.35                 Enzyme
NAME        3-hydroxyacyl-CoA dehydrogenase;
            beta-hydroxyacyl dehydrogenase;
            beta-keto-reductase;
            3-keto reductase;
            3-hydroxyacyl coenzyme A dehydrogenase;
            beta-hydroxyacyl-coenzyme A synthetase;
            beta-hydroxyacylcoenzyme A dehydrogenase;
            beta-hydroxybutyrylcoenzyme A dehydrogenase;
            3-hydroxyacetyl-coenzyme A dehydrogenase;
            L-3-hydroxyacyl coenzyme A dehydrogenase;
            L-3-hydroxyacyl CoA dehydrogenase;
            beta-hydroxyacyl CoA dehydrogenase;
            3beta-hydroxyacyl coenzyme A dehydrogenase;
            3-hydroxybutyryl-CoA dehydrogenase;
            beta-ketoacyl-CoA reductase;
            beta-hydroxy acid dehydrogenase;
            3-L-hydroxyacyl-CoA dehydrogenase;
            3-hydroxyisobutyryl-CoA dehydrogenase;
            1-specific DPN-linked beta-hydroxybutyric dehydrogenase
CLASS       Oxidoreductases;
            Acting on the CH-OH group of donors;
            With NAD+ or NADP+ as acceptor

Is there a way to retrieve substrate , Product, enzyme class and interacting pathway using KEGG API and script if you have multiple number of EC numbers and Reaction number from KEGG. EC 1.1.1.35 EC 1.1.1.100 and so on

and rn:R1135 rn:R05233

Log in to answer this question.