Lookup field in map file | Unix Linux Forums | UNIX for Dummies Questions & Answers

  Go Back    


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

Lookup field in map file

UNIX for Dummies Questions & Answers


Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 05-07-2013
genehersh genehersh is offline
Registered User
 
Join Date: May 2013
Last Activity: 8 May 2013, 12:27 PM EDT
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Lookup field in map file

Hi,

I have two questions which I would massively appreciate help with.

1.

I am trying to insert a field into a file similar to the vlookup function in excel. In column 2 is a gene id for which i would like to insert the full name in the adjacent column. I have a map file (map.file) which has two columns - in column 1 is the gene ID and column 2 is the full gene name


Code:
inputfile.txt
Func	Gene	ExonicFunc	AAChange	Conserved	SegDup	1000g2010nov_ALL	1000g2011may_ALL	1000g2012feb_ALL
exonic	GABRD	synonymous SNV	c.C816T:p.S272S	660;Name=lod=640		0.15	0.34	0.19
exonic	PRKCZ	synonymous SNV	c.T264C:p.D88D	343;Name=lod=33		0.66	0.73	0.63
exonic	PRKCZ	synonymous SNV	c.A318G:p.P106P	389;Name=lod=51		0.21	0.36	0.24

map.file
Gene ID  Full Gene name
GABRD  Gamma-aminobutyric acid receptor subunit delta
PRKCZ    protein kinase c, zeta

desired output

Func	Gene	GeneName ExonicFunc	AAChange	Conserved	SegDup	1000g2010nov_ALL	1000g2011may_ALL	1000g2012feb_ALL
exonic	GABRD  Gamma-aminobutyric acid receptor subunit delta	synonymous SNV	c.C816T:p.S272S	660;Name=lod=640		0.15	0.34	0.19
exonic	PRKCZ protein kinase c, zeta	synonymous SNV	c.T264C:p.D88D	343;Name=lod=33		0.66	0.73	0.63
exonic	PRKCZ protein kinase c, zeta	synonymous SNV	c.A318G:p.P106P	389;Name=lod=51		0.21	0.36	0.24

The second query I have is that i want to be able to filter the file so that the output only contains those fields where for example column 7 <0.5 and column 8 <0.3 and column 9 <0.2 (sometimes there is just a blank in the field which effectively equals 0)

Is there a way to do this so that the filtering is done based on the column header rather than the column number as I have different files which have a different arrangement of columns but with the same headers.

Sorry for the complicated question.

Thanks
Sponsored Links
    #2  
Old 05-07-2013
Don Cragun's Avatar
Don Cragun Don Cragun is online now Forum Staff  
Moderator
 
Join Date: Jul 2012
Last Activity: 27 November 2014, 2:41 AM EST
Location: San Jose, CA, USA
Posts: 5,103
Thanks: 196
Thanked 1,706 Times in 1,449 Posts
If you religiously used tab as your field separator and only used spaces as data in fields, everything that you're asking for could be done (and has been done several times in this forum). But, when you sometimes use one or two spaces as a field separator AND use spaces as data within a field (as you have done in your examples above), there is no way to programmatically determine where one field ends and the next begins AND there is no way to determine whether a field is empty in the middle of the line or missing at the end of the line.

If you can clean up the source of your data so that you have a consistent field separator, please repost sample input files and the describe (in English) and provide sample output files to more fully describe how you would identify fields to be processed and we may be able to help you.
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
File field to replace lookup from another file ckwong99 Shell Programming and Scripting 0 04-19-2013 07:05 AM
Help with AWK - Compare a field in a file to lookup file and substitute if only a match venalla_shine UNIX for Dummies Questions & Answers 4 10-08-2012 04:46 PM
Append 1st field from a file into 2nd field of another file amurib Shell Programming and Scripting 1 12-25-2010 06:13 AM
Mail issue solution query- host map: lookup (domain): deferred DNT Solaris 0 09-28-2010 08:18 AM
Clueless about how to lookup and reverse lookup IP addresses under a file!!.pls help choco4202002 UNIX for Advanced & Expert Users 0 08-26-2008 02:28 PM



All times are GMT -4. The time now is 04:05 AM.