Sponsored Content
Full Discussion: Tricky sed or awk question
Top Forums Shell Programming and Scripting Tricky sed or awk question Post 302428184 by pseudocoder on Wednesday 9th of June 2010 05:43:59 AM
Old 06-09-2010
Code:
$ cat abc.dat
a,b,C-D-E,f,g
h,i,J,k,l
m,n,O-P-Q-R-S,t,u
v,w,X-Y,z,a
$ perl -ane '@x=split(/,/,$_); @y=split(/-/,$x[2]);
foreach $char (@y) { print "$x[0],$x[1],$char,$x[3],$x[4]"; }' abc.dat
a,b,C,f,g
a,b,D,f,g
a,b,E,f,g
h,i,J,k,l
m,n,O,t,u
m,n,P,t,u
m,n,Q,t,u
m,n,R,t,u
m,n,S,t,u
v,w,X,z,a
v,w,Y,z,a
$


Last edited by pseudocoder; 06-09-2010 at 06:56 AM.. Reason: small correction :grin:
This User Gave Thanks to pseudocoder For This Post:
 

10 More Discussions You Might Find Interesting

1. Filesystems, Disks and Memory

Tricky File Permission Question

I'm trying to answer the following question about file permissions in Unix. Consider a file with the following permissions: rwx---r-- I am not the owner of this file, but I am a member of the group of this file. My question is: do I have read access to this file? I thought... (3 Replies)
Discussion started by: Hook
3 Replies

2. Shell Programming and Scripting

Tricky Sed

Hello. I am trying to convert occurrences of 'NULL' from a datafile. The 'NULL' occurences appears at this: |NULL| NULL|NULL| NULL|NULL| NULL|NULL| NULL| There should be 52 fields per line. I would like any occurrence of | NULL| or |NULL| to appear as '||' Currently I am using this sed... (2 Replies)
Discussion started by: bestbuyernc
2 Replies

3. Shell Programming and Scripting

Tricky script question

Hi, I'm in the midst of writing a UNIX script that sftp's files to an external host and am stuck with a problem. The problem is that the files created on my server as a order number that correlates to a sequence of directories on the remote host which is where the file should be ftp'ed. ... (3 Replies)
Discussion started by: budrito
3 Replies

4. UNIX for Dummies Questions & Answers

Tricky Quotation Question

Hi, I am at a point in my script where I defined the number of the command line parameter I would like to set a variable equal to: parameter_number=14 I would then like to set a variable equal to the correct parameter: variable=$parameter_number The issue here is that {} is required... (2 Replies)
Discussion started by: msb65
2 Replies

5. Shell Programming and Scripting

sed or awk question

Hello expert, I have an output file with few thousand lines similar like below : "Future Netmgmt" "10.99.16.0" "N" "10" "10.0.0.0" "Circuitless-IP" " " "255.255.254.0" "Future Netmgmt" "10.99.18.0" "N" "10" "10.0.0.0" "Circuitless-IP" " " "255.255.254.0" "WAAS loopbacks" "10.99.20.0"... (6 Replies)
Discussion started by: dannytrinh
6 Replies

6. Shell Programming and Scripting

Another tricky sed or awk question

This post is in reference to https://www.unix.com/shell-programming-scripting/137977-tricky-sed-awk-question-post302428154.html#post302428154 I am trying to go the opposite direction now: I have the following file: a,b,C,f,g a,b,D,f,g a,b,E,f,g h,i,J,k,l m,n,O,t,u m,n,P,t,u m,n,Q,t,u... (3 Replies)
Discussion started by: awayand
3 Replies

7. Shell Programming and Scripting

sed tricky problem

Hi, I have a file which contains two strings: AAAAA and BBBBB I have two variables in my script: DATE="03/21/2010" aDate="20100321" I need to replace string AAAAA with variable $DATE and BBBBB with $aDate. Here is what I do sed "s/AAAAA/$DATE/" $BASIC_TMPLT | sed "s/BBBBB/$aDate/" >... (4 Replies)
Discussion started by: axed
4 Replies

8. UNIX for Dummies Questions & Answers

Tricky GREP question..

I have some large login files that I need to extract (user)@(server) from. Where it gets tricky is that there is usually more than one '@' sign on each line(although it does have a leading space if it's not part of the (user)@(server) string), I need only the (user)@(server) section, I need only... (6 Replies)
Discussion started by: Mordaris
6 Replies

9. Shell Programming and Scripting

Tricky BASH quoting question

I have some data files that I can identify by a certain pattern in the names using find. Every one of those data files has an XML file associated with it (can be multiple data files per XML file). The XML file is always up one directory from the data file(s) in a folder calledRun##### -... (12 Replies)
Discussion started by: Michael Stora
12 Replies

10. Shell Programming and Scripting

Tricky sed required

Hi All I need to put some sed together for a task and its a bit advanced for me, so I thought I'd ask if anyone here could help. I have a csv file with content like this - "","abcde","","" "'","abcde","","" "","","","1234" "'e'","","","" I need to remove any single quotes that fall... (17 Replies)
Discussion started by: steadyonabix
17 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 10:30 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy