Kindly check it: Camparison of files only column1 of 2 files


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Kindly check it: Camparison of files only column1 of 2 files
# 1  
Old 07-27-2012
Kindly check it: Camparison of files only column1 of 2 files

Hi all,

I have 2 files in which i have to find commom entries in column 1 an dif soemthing is common write other data of both files in front of it mentioned.

Gene symbol and disease name

Code:
column 1    column2
ARFGEF2 CAD
DDEF2 CAD
PSCD3 CAD
PSCD4 CAD
CAMK1 CAD,HT,HT,HT,HT,HT,HT,HT,HT,HT,HT,HT,HT
HSP90AA1 CAD,CAD,CAD,T2D,T2D
KDR CAD,CD,CD
VEGF CAD,CAD,CAD,CAD,T2D,T2D,T2D
CTNNA3 CAD,HT,T2D
PTPRM CAD,T2D
RAC2 CAD,CAD,T1D,T1D
SMAD3 CAD,T2D,T2D,T2D,T2D,T2D,T2D,T2D
SORBS1 CAD,CAD,CAD
CD36 CAD
IRS1 CAD,CAD,CAD
IRS2 CAD,CAD,CAD,CAD
MTFMT CAD,CAD,CAD,T1D,T1D,T1D
SARS CAD
GNPDA2 CAD
NANS CAD
SRD5A1 CAD

Second file with 3 colu

second file is like this


Gene symbol drug drug
Code:
F2        Lepirudin    Refludan
FCGR2A,FCGR2B,FCGR2C,EGFR,FCGR3B,C1R,C1QA,C1QB,C1QC,FCGR3A,C1S,FCGR1A        Cetuximab    Erbitux
Not Available        Dornase Alfa    Pulmozyme
IL2RA,IL2RB,IL2RG        Denileukin diftitox    Ontak
C1S,C1R,C1QA,C1QB,C1QC,TNF,TNFRSF1B,FCGR1A,FCGR3A,FCGR2A,FCGR2B,FCGR2C,LTA,FCGR3B        Etanercept    Enbrel
F2        Bivalirudin    Angiomax
GNRHR        Leuprolide    Eligard
IFNAR2,IFNAR1        Peginterferon alfa-2a    Pegasys
PLG,FGA,PLAUR,SERPINE1        Alteplase    Activase (Genentech Inc

The expected out put contain
Code:
common entries of first column                        disease from first file                         drug from second file                drug from second file


Last edited by Scott; 07-27-2012 at 03:04 AM.. Reason: Code tags
# 2  
Old 07-27-2012
I didnt get u properly.. can u explain a bit..
# 3  
Old 07-27-2012
hi

thanks for ur reply.

I have to compare entries in coumn 1 o ffirst file with entries in column 1 of secoond file both are gene names in capitalised letters.

And, if there is a gene naem for exaple IFNAR1 is common in first column of both files then I have to write the entries of second file and and first file in front of it. so that I will get 4 columns in out put file

first column: common gene entry
secoond column: disease name in front of common entry in first file(CAD,HT)
third column drug in second filein front of common entry
fourth column drug in second file in front of common entry

Please let me know if u need any other information.

Mani
# 4  
Old 07-27-2012
join

Hi,

Try this,
Code:
join -11 -21 file1 file2

Cheers,
Ranga:-)
# 5  
Old 07-27-2012
Request to check

Hi

thanksf orr reply.
The output is completely blank!

Code:
bash-3.2$ join -11 -21 SARAIN_FILE drugbankin_file >sara-drugbankout
bash-3.2$ join -11 -21 SARAIN_FILE drugbankin_file
bash-3.2$ join -11 -21 SARAIN_FILE drugbankin_file
bash-3.2$ join -11 -21 SARAIN_FILE drugbankin_file
bash-3.2$ join -11 -21 SARAIN_FILE drugbankin_file
bash-3.2$


Last edited by Scott; 07-27-2012 at 03:05 AM.. Reason: Code tags
# 6  
Old 07-27-2012
Sorry i didnt get you. can you exaplain with some examples. I didnt get the examples which you specified above..
# 7  
Old 07-27-2012
Alright for example

1 file contains data in 3 columns
Code:
column1         col2     col3     
1,2,3                c          d 
4                     g          h 
6,7                  k           c

second file contain 2 columns

Code:
1  x
2  u
3  s
4  l

output shuld be check common entreis in column 1 of both files and write the data before it like this as mentione din file 1 and file 2

Code:
1  x    c  d 
2  u   c  d 
3  s   c   d 
4  l    g h


Last edited by manigrover; 07-27-2012 at 07:16 AM.. Reason: Code tags
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to get CRC check sum of files in java EAR file without extracting .jar/.war files to disk.?

unzip -v gives CRC info of each file in a zip(in my case .EAR) file. # unzip -v my-application.ear Archive: my-application.ear Length Method Size Cmpr Date Time CRC-32 Name -------- ------ ------- ---- ---------- ----- -------- ---- 197981 Defl:N 183708 7%... (1 Reply)
Discussion started by: kchinnam
1 Replies

2. Shell Programming and Scripting

Check files and archive the files using sftp

Hi, I have to check the files in another server using sftp to do that, below is the code i am going with #!/bin/bash export SRC_FOLDER=$1 export ARC_FOLDER=$2 HOST=as07u3456 USER=relfag sftp ${USER}@${HOST} <<EOF cd $SRC_FOLDER/DSCOR ls bye EOF echo "done" whatever the files i... (8 Replies)
Discussion started by: ursrami
8 Replies

3. Shell Programming and Scripting

common entries of first column in 2 or 3 files:kindly check

Hi all, I have 3 files with such data first files second file third file I have to find common entries of first column in two ways 1) between 2 files (2 Replies)
Discussion started by: manigrover
2 Replies

4. Shell Programming and Scripting

Kindly check:remove duplicates with similar data in front of it

Hi all, I have 2 files containing data like this: so if there is same entry repeated in the column like1,2,3,4 I have to check if there is different entries column like 2,4 but similar entries for duplicatein column 2 like1,3 the output shuld be like this for first file ... (5 Replies)
Discussion started by: manigrover
5 Replies

5. Shell Programming and Scripting

Perl code to check date and check files in particular dir

Hi Experts, I am checking how to get day in Perl. If it is “Monday” I need to process…below is the pseudo code. Can you please prove the code for below condition. if (today=="Monday" ) { while (current_time LESS THAN 9:01 AM) ... (1 Reply)
Discussion started by: ajaypatil_am
1 Replies

6. Shell Programming and Scripting

need a shell script to extract the files from source file and check whether those files existonserve

Hi, I am new to shell scripting.Please help me on this.I am using solaris 10 OS and shell i am using is # echo $0 -sh My requirement is i have source file say makefile.I need to extract files with extensions (.c |.cxx |.h |.hxx |.sc) from the makefile.after doing so i need to check whether... (13 Replies)
Discussion started by: muraliinfy04
13 Replies

7. Shell Programming and Scripting

How to change value in CSV columns and compare two files where Column1 is identical

Hi all, Could someone help me with the following issue: 1st I have an CSV file delimiter is ";" I I have a column 7 where I need to do some multiple mathem. operation, I need all values in this columns to be multiplied by 1.5 and create a new CSV file with the replaced values. 2nd. I... (3 Replies)
Discussion started by: kl1ngac1k
3 Replies

8. Shell Programming and Scripting

How to check files and move the results to differents files?

Hi, I am a newbie to shell scripting. here is my objective: 1)The shell program should take 2 parameters - ie-> DestinationFolder, WebFolder 2)Destination folder contains few files that has to has be verified and deleted. 3)WebFolder is a folder containing a list of master files 4)It... (1 Reply)
Discussion started by: sandhyagupta
1 Replies

9. Shell Programming and Scripting

check how many files in folder or total files in folder

Hi all, I have copied all my files to one folder.and i want to check how many files (count) in the folder recently moved or total files in my folder? please send me the query asap. (3 Replies)
Discussion started by: durgaprasad
3 Replies

10. Shell Programming and Scripting

comparing 2 files - kindly assist expert

Hi, I'm new in shell scripting and would like u guys to help on this. OS: Solaris 9 currently, i have 2 files. file1: hello hi test god file2: hi hello file1 is my masterfile, and i wanted to print out string that are in file1 and NOT in file2 and send out a mail (with the... (15 Replies)
Discussion started by: chew
15 Replies
Login or Register to Ask a Question