Remove brackets repeats and separate in columns


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Remove brackets repeats and separate in columns
# 1  
Old 08-10-2012
Remove brackets repeats and separate in columns

Hi all,


I want to remove the remove bracket sign ( ) and put in the separate column I also want to remove the repeated entry like in first row in below input (PA156) is repeated


Code:
ESR1 (PA156) leflunomide (PA450192)  (PA156) leflunomide (PA450192) 
CHST3 (PA26503) docetaxel (PA449383);thalidomide (PA451644)  (PA26503)  docetaxel (PA449383);thalidomide (PA451644)  (PA26503) docetaxel  (PA449383);thalidomide (PA451644)  (PA26503) docetaxel  (PA449383);thalidomide (PA451644)  (PA26503) docetaxel  (PA449383);thalidomide (PA451644)  (PA26503) docetaxel  (PA449383);thalidomide (PA451644)  (PA26503) docetaxel  (PA449383);thalidomide (PA451644) 
LPL (PA232) fenofibrate (PA449594) 
GALNT14 (PA134920089) cisplatin (PA449014);fluorouracil  (PA128406956);mitoxantrone (PA450526)  (PA134920089) cisplatin  (PA449014);fluorouracil (PA128406956);mitoxantrone (PA450526)   (PA134920089) cisplatin (PA449014);fluorouracil  (PA128406956);mitoxantrone (PA450526)  (PA134920089) cisplatin  (PA449014);fluorouracil (PA128406956);mitoxantrone (PA450526)   (PA134920089) cisplatin (PA449014);fluorouracil  (PA128406956);mitoxantrone (PA450526)  (PA134920089) cisplatin  (PA449014);fluorouracil (PA128406956);mitoxantrone (PA450526)   (PA134920089) cisplatin (PA449014);fluorouracil  (PA128406956);mitoxantrone (PA450526) 
CTLA4 (PA27006) glatiramer acetate (PA449760

I want output for first row and other rows shuld be like this format




Code:
ESR1  PA156  leflunomide  PA450192  leflunomide PA450192

# 2  
Old 08-10-2012
PA450192 is also repeated (and within parentheses) in the first row. Why is it still in 2 places in the expected output?
# 3  
Old 08-10-2012
Request to check

Thanks for reply.

If it is possible to remove the second repetition of another columns entries in the same row that shuld be fine

No Prob with that

Its alright to remove
initially I was thinking to remove remove repetition o first entry but if we can remove the others as well that should be fine


Quote:
ESR1 PA156 leflunomide PA450192
# 4  
Old 08-10-2012
This will remove repeated occurences of only those fields containing parentheses.
Code:
awk -v p="[()]" '{
for(i=1;i<=NF;i++)
 if(gsub(p,"",$i))
  if(++a[$i]>1) 
   $i=""
for(i in a)
 delete a[i]
}1' infile

# 5  
Old 08-10-2012
Request to check

Thankyou

can I remove brackets and things between 2 brackets in a separate column.

as well as means there shuld be 4 columns for first row and in the same row for others as these are not present actually in input file

Code:
ESR1 PA156 leflunomide PA450192


Mani
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

How to use "awk" to print columns from different files in separate columns?

Hi, I'm trying to copy and paste the sixth column from a bunch of files into a single file having each column pasted in separate columns (and not one after each other in just one column.) I tried this code but works only partially because it copied and pasted 50 rows of each column... (6 Replies)
Discussion started by: Frastra
6 Replies

2. Shell Programming and Scripting

Separate columns into different text files

Hi I have large text file consisting of five columns. Sample of the file is give below: ed 2-4 12.0 commons that they depended on. मानवों नष्ट किया जिन पर वो आधारित थे। ed 3-1 12.0 Almost E, but would be over. रचना करीब करीब ई तक जाती है, मगर तब तो नाटक ख़त्म हो... (2 Replies)
Discussion started by: my_Perl
2 Replies

3. Shell Programming and Scripting

Remove multiline text between brackets

I have some text in a file like so This is {the first day of} my life. What I would like as output is This is my life. Any text between the curly braces is removed. In the forums I've found statements like sed 's/<*>//g' but the problem is that I think that... (12 Replies)
Discussion started by: climatron
12 Replies

4. Shell Programming and Scripting

Remove everything inside of brackets

I need to use something bash related to remove everything inside of brackets. For example. In the following: abc<def>ghi<jkl>mno the result should be: abcghimno (4 Replies)
Discussion started by: locoroco
4 Replies

5. UNIX for Dummies Questions & Answers

Intersect of two columns in two separate files

Hi, I have a file like this: abc def ghi jkl mno My second file is like this (tab delimited): adsad sdfsdf dfdf wads abc dfdsf sdsf jkl sfsdf dsfds sdfd reor zxczd dsf sff Now, I want the code to report the lines (from file2) which have common strings in column 2 with the first... (4 Replies)
Discussion started by: a_bahreini
4 Replies

6. Shell Programming and Scripting

Remove whatever is mention in brackets

Hi all My previous question was complicated let me simplify it I have to just remove whatever is present in bracket () along with brackets ERCC1 (PA155) Platinum compounds (PA164713176) Allele A is not associated with response to Platinum compounds in women with Ovarian Neoplasms as... (2 Replies)
Discussion started by: Priyanka Chopra
2 Replies

7. Shell Programming and Scripting

Separate into columns

Hi all I have following kind of data in a file but non separated ESR1 PA156 leflunomide PA450192 CHST3 PA26503 docetaxel tungstate Pa4586; thalidomide Pa34958; I want to separate entries into columns so that I can put into excel sheet in proper arrangement. I want entries... (4 Replies)
Discussion started by: manigrover
4 Replies

8. Shell Programming and Scripting

remove brackets and put it in a column and remove repeated entry

Hi all, I want to remove the remove bracket sign ( ) and put in the separate column I also want to remove the repeated entry like in first row in below input (PA156) is repeated ESR1 (PA156) leflunomide (PA450192) (PA156) leflunomide (PA450192) CHST3 (PA26503) docetaxel... (2 Replies)
Discussion started by: manigrover
2 Replies

9. Shell Programming and Scripting

Remove brackets { } in the data

Hello folks, I have a data file in which each line has 54 numbers, and every 3 numbers are bracketed. So totally 18 pairs of brackets in each line. A typical line is like: {29.187000274658203 -16.148000717163086 -0.9380000233650208} {30.63800048828125 -15.977999687194824... (5 Replies)
Discussion started by: rockytodd
5 Replies

10. Shell Programming and Scripting

Remove text between brackets

How can I use bash to remove all text between "<" and ">" in a file? (1 Reply)
Discussion started by: locoroco
1 Replies
Login or Register to Ask a Question