0

I have this input file

Name=code_229633_138;isoforms=1          
Name=code_229633_138            
Name=code_229633_138;Target=R77_09738T0

Name=code_230519_1;isoforms=1            
Name=code_230519_1          
Name=code_230519_1;Target=R77_13591T0

Name=code_299097_0;isoforms=2            
Name=code_299097_0          
Name=code_299097_0;Target=R77_15554T0 
Name=code_299097_0          
Name=code_299097_0;Target=R77_14520T0 

Name=code_010512_23;isoforms=1           
Name=code_010512_23         
Name=code_010512_23;Target=R77_14520T0

Name=code_550_30;isoforms=3
Name=code_550_29
Name=code_550_29;Target=R77_14520T0  
Name=code_550_31
Name=code_550_31;Target=R77_13591T0
Name=code_550_31;Target=R77_13591T0
Name=code_550_32
Name=code_550_32;Target=R77_13771T0

Name=code_67379_19;isoforms=2
Name=code_67379_19
Name=code_67379_19;Target=R77_14095T0
Name=code_67379_19
Name=code_67379_19;Target=R77_00109T0

and I would like to sensitive replace the "code_xxxxxx_xxx" sections only in the first lines which are containing the word "isoforms" (lines 1, 5, 10, 16, 20, 27) with all the "Target" values (R77_xxxxxT0) that are found in each of the 6 records, respectivelly and separate them by a "/" if there are up to 2 isoforms per record. I need also these replacements to take into account how many times each of the "Target" values are found in the text and accordingly to add a proper suffix when they would replace the "code_xxxxxx_xxx" section in the first lines. Finaly, I would prefer the series of the "Target" values in each replacement to follow the series that these Target values are displayed in each of the 6 records in the initial input file.

I would expect the following output:

Name=R77_09738T0;isoforms=1          
Name=code_229633_138            
Name=code_229633_138;Target=R77_09738T0

Name=R77_13591T0.a;isoforms=1            
Name=code_230519_1          
Name=code_230519_1;Target=R77_13591T0

Name=R77_15554T0/R77_14520T0.a;isoforms=2            
Name=code_299097_0          
Name=code_299097_0;Target=R77_15554T0  
Name=code_299097_0          
Name=code_299097_0;Target=R77_14520T0

Name=R77_14520T0.b;isoforms=1           
Name=code_010512_23         
Name=code_010512_23;Target=R77_14520T0

Name=R77_14520T0.c\R77_13591T0.b\R77_13771T0;isoforms=3
Name=code_550_29
Name=code_550_29;Target=R77_14520T0  
Name=code_550_31
Name=code_550_31;Target=R77_13591T0
Name=code_550_31;Target=R77_13591T0
Name=code_550_32
Name=code_550_32;Target=R77_13771T0

Name=R77_14095T0\R77_00109T0;isoforms=2
Name=code_67379_19
Name=code_67379_19;Target=R77_14095T0
Name=code_67379_19
Name=code_67379_19;Target=R77_00109T0 

The following script (case sensitive substitution; same target ids) was quite helpful to make simple replacements and add suffixes when it was needed. Any possible improvements?

  • possible duplicate of case sensitive substitution; same target ids – MelBurslan Mar 5 '14 at 21:27
  • This is clearly different from what the original was. The correct thing to do is to put it in a separate question as per here instead of tagging it on to the end of the other one after it had been answered. Although the duplicate part should be removed from the other question. – Graeme Mar 6 '14 at 1:54
  • Thanks Graeme for your suggestion. I think i had to submit this question as a different one; what you mean to remove the duplicate part from the other question (removing the input file and the output part)? – user61677 Mar 6 '14 at 9:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.