Sponsored Content
Top Forums Shell Programming and Scripting Assign 1,2,3 according to the names using Awk Post 302426775 by ruby_sgp on Wednesday 2nd of June 2010 11:47:55 PM
Old 06-03-2010
Assign 1,2,3 according to the names using Awk

Print same letters as 1 or 3 (ex:a/a)and different letters as 2 (ex:a/b)
based on Name and subname

1st column indicates main names (ex: ID1 is one main name) and 2nd column indicates sub names (ex: a1 is a subname of ID1) and 3rd column indicates sub-sub names (ex: a/b is a sub-sub name of ID1)

input

Code:
ID1     a1      a/b      
ID1     a10     a/b      
ID1     a2      a/b      
ID1     a3      a/a      
ID1     a6      b/b      
ID2     a1      b/b      
ID2     a10     b/b      
ID2     a2      b/b      
ID2     a3      b/b      
ID2     a6      b/c      
ID2     a8      d/d      
ID3     a1      c/c      
ID3     a10     c/c      
ID3     a2      c/d      
ID3     a3      e/e      
ID3     a6      e/e      
ID3     a8      e/e 

output

Code:
ID1     a1      a/b      2
ID1     a10     a/b      2
ID1     a2      a/b      2
ID1     a3      a/a      1
ID1     a6      b/b      3
ID2     a1      b/b      1
ID2     a10     b/b      1
ID2     a2      b/b      1
ID2     a3      b/b      1
ID2     a6      b/c      2
ID2     a8      d/d      3
ID3     a1      c/c      1
ID3     a10     c/c      1
ID3     a2      c/d      2
ID3     a3      e/e      3
ID3     a6      e/e      3
ID3     a8      e/e      3 

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

assign value to variable using AWK

Dear Friends I have text file as like below, AAAAA|BHBHBH|VERYSMART AAAAA| KKKKKK|GOOD BBBBBB|JJJJJJJ|VERYGOOD CCCCC|HJHJHJ|BETTER CCCCC|UUUUU|GOOD i need to split into seperate files based on column 1 like as below AAAAA.TXT contains -------------------- BHBHBH.VERYSMART... (4 Replies)
Discussion started by: HAA
4 Replies

2. Shell Programming and Scripting

assign values from awk output - help

Dear All, I have a command which gives the number of fields of each line of a comma-separated file. sthng like this : cat QDB_20071126_002.bad | awk -F"," '{ print NF }' I need to assign the first output and the last output of the above command to variables in a script. Need help to do... (4 Replies)
Discussion started by: KrishnaSaran
4 Replies

3. Shell Programming and Scripting

assign awk array with printf

I am trying to assign a awk array for further processing later in the script. I can't seem to figure it out. If someone could look at this and help me, I would very much appreciate it. Thanks in Advance. for ( x = 1 ; x <= Var ; x++ ) { if ( x in varr ) { ... (2 Replies)
Discussion started by: timj123
2 Replies

4. Shell Programming and Scripting

Assign o/p of awk to a variable

:confused: Hi UNIX gurus, I am facing a typical problem while assigining while assigining output of awk to a variable. I have a fixed length file say myinputfile.txt When I allow the value/output of an awk to be redirected to a file, it works fine. i.e. awk "/^.{232}$acctNum/ {... (8 Replies)
Discussion started by: c2b2
8 Replies

5. Shell Programming and Scripting

awk: assign variable with -v didn't work in awk filter

I want to filter 2nd column = 2 using awk $ cat t 1 2 2 4 $ VAR=2 #variable worked in print $ cat t | awk -v ID=$VAR ' { print ID}' 2 2 # but variable didn't work in awk filter $ cat t | awk -v ID=$VAR '$2~/ID/ { print $0}' (2 Replies)
Discussion started by: honglus
2 Replies

6. Shell Programming and Scripting

Read variables names from array and assign the values

Hi, I have requirement to assign values to variables which are created dynamically. Below is the code which i am using to achieve above requirement. #!/bin/ksh oIFS="$IFS"; IFS=',' STR_FAIL_PARENT_IF_FAILS="WF_F_P_IF_FAILS1,WF_F_P_IF_FAILS2,WF_F_P_IF_FAILS3" set -A... (1 Reply)
Discussion started by: tmalik79
1 Replies

7. Shell Programming and Scripting

help on awk---- need to assign the output of awk to a variable

hi i want to find the size of a folder and assign it to a variable and then compare if it is greater than 1 gb. i am doin this script, but it is throwing error.... #!/bin/ksh cd . | du -s | size = awk '{print $1}' if size >= 112000 then echo size high fi ERROR : (4 Replies)
Discussion started by: Nithz
4 Replies

8. Shell Programming and Scripting

how to assign file names to array variable?

I wish to assign file names with particular extention to array variables. For example if there are 5 files with .dat extention in /home/sam then i have to assign these 5 files to an array. plz help me how to accomplish this. Thanks in advance. (4 Replies)
Discussion started by: siteregsam
4 Replies

9. Shell Programming and Scripting

Assign a variable with awk

I launch 'netstat -a', if string 'ESTABLISHED' found, then VAR=1 #!/bin/bash VAR=0; netstat -a | awk '$6 ~ /ESTABLISHED/ {VAR=1}' I cannot find the right syntax. thanx guys! (3 Replies)
Discussion started by: arpagon
3 Replies

10. UNIX for Beginners Questions & Answers

How to assign a value to a variable in awk scripting?

Hi, I am trying to assign a value using below command and it is assigning the command to the variable not the output of the command? out_value="echo $0 | cut -c 9-11"; How can i assign the output to the variable instead of whole command? This is inside my awk script (7 Replies)
Discussion started by: bhagya123
7 Replies
mcxdeblast(1)							  USER COMMANDS 						     mcxdeblast(1)

  NAME
      mcxdeblast - parse BLAST files and stream output directly into mcl or write mcxassemble input.

  SYNOPSIS
      mcxdeblast file-name

      mcxdeblast  [--score=<b|e|r>  (bit  scores|e-values|normalize  bit score)] [--m9 (expect BLAST column format)] [--out <fname> (output file)]
      [--line-mode abc (write ID1 ID2 score format)] [--sort=<a|o> (alphabetic|occurrence sorting)] [--xi-dat=<suf> (strip <suf> from  file-name)]
      [--xo-dat=<suf>  (add  <suf>  to base name)] [--bcut=<val> (bit score cutoff)] [--ecut=<val> (E-value cutoff)] [--rcut=<val> (raw value cut-
      off)] [--tab=<fname> (tab file)] <file-name>

  DESCRIPTION
      mcxdeblast parses BLAST files.

      In stream mode mcxdeblast output can be directly streamed to mcl by using the mcxdeblast	--line-mode=abc  option  and  equipping  mcl  with
      either --abc or --expect-abc. This can be considered the easy, lightweight and fast track. This functionality was recently acquired by mcl.

      In the classic and slightly more heavy-handed assemble mode, mcxdeblast creates output files suitable for use by mcxassemble. The latter can
      in turn create input suitable for mcl. This is the mode in which mcxdeblast is employed by mclblastline.

  STREAM MODE
      Enter stream mode by specifiying --line-mode=abc.  Use --m9 if the input is in columnar output. Pipe the result to a  file  or  directly	to
      mcl. Example invocations can be found in the mcl manual.

  ASSEMBLE MODE
      If  the input file is named iput, mcxdeblast will by default create files iput.hdr, iput.raw, iput.tab, iput.map, and iput.err. The hdr file
      contains information about the number of nodes found. It will be read by mcxassemble. The raw file contains the co-occurrence scores between
      different  nodes (peptides), also to be read by mcxassemble. The co-occurrence scores are in terms of mcl indentiers, which are subjected to
      rearranging by mcxassemble in order to correctly align them with the tab file.  The tab  file  contains  bindings  between  mcl  identifiers
      (after rearranging as specified in the map file) and the BLAST labels (peptide identifiers). Refer to the manual of mcxassemble for the syn-
      tax of a tab file.  The err file contains a list of any errors encountered.

      If the --tab=fname option is used mcxdeblast changes its behaviour. It will read the file fname, and use the bindings found therein. It will
      no longer output any of the hdr, map, or tab files. The hdr file should be provided by the same application that generated the specified tab
      file, and the map file should no longer be necessary (it might be convenient though and perhaps the future will bring a new --map option).

      The --tab=fname option can be convenient e.g. if you split a BLAST job over multiple machines and want to apply mcxdeblast to  each  of  the
      subresults.  You	do  this by generating a single central tab file in advance.  Then provide each instance of mcxdeblast with this tab file.
      Each instance will generate a raw file. The respective raw files can simply be concatenated and fed to mcxassemble using	its  -raw  option.
      Additionally,  a hdr file has to be specified for mcxassemble using its -hdr option. The syntax of hdr files is described in the mcxassemble
      manual.  Currently there is usually only one variable in the hdr file, which is the number of bindings listed in the tab file. This  number,
      in turn, should equal the total number of different peptides encountered in the BLAST input.

  OPTIONS
      --tab=<fname> (tab file)
	Specify a tab file to use, rather than automatically generating one.

      --out <fname> (output file)
	Specify the name for the output file.

      --score=<b|e|r> (bit scores|e-values|norm bit score)
	Specify whether to use bit scores, E-values, or bit scores normalized by length of the HSP.

      --sort=<a|o> (alphabetic|occurrence sorting)
	Specify how to sort labels.

      --m9 (expect BLAST column format)
	Use this option to parse BLAST output formatted with the -m 9 option.

      --line-mode=abc (write ID1 ID2 SCORE format)
	Use this to stream output directly into mcl. Here abc is a literal; --line-mode may acquire other line output modes.

      --xi-dat=<suf> (strip <suf> from <file-name>)
	If  set, the suffix <suf> is stripped from file-name in order to obtain the base name for output. If <file-name> does not end with suffix,
	it is assumed to be the base name, and <suf> is added in order to obtain the (real) file-name.

      --xo-dat=<suf> (add <suf> to base name)
	Attaches the suffix to the base name. Use this to distinguish between different parses. One might for example use --score=b --bcut=5 --xo-
	dat=b.

      --bcut=<val> (bit score cutoff)
	Bit scores below the cutoff value are ignored. This triggers the output of bit scores and ignores all other values.

      --ecut=<val> (E-value cutoff)
	E-values below the cutoff value are ignored. This triggers the output of E-values and ignores all other values.

      --rcut=<val> (raw value cutoff)
	Raw values below the cutoff value are ignored. This triggers the output of raw values and ignores all other values.

  AUTHOR
      Stijn  van  Dongen.   Jason Stajich implemented the --m9 option.	Abel Ureta-Vidal and Dinakarpandian Deendayal contributed helpful comments
      and fixes.

  SEE ALSO
      mclblastline, mcxassemble, mcl, clmformat.

  mcxdeblast 12-068						      8 Mar 2012						       mcxdeblast(1)
All times are GMT -4. The time now is 08:28 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy