Visit Our UNIX and Linux User Community


Execution problem with repeat the same program with two set of same data


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Execution problem with repeat the same program with two set of same data
# 8  
Old 10-11-2009
Hi, Franklin52.
The code that you suggestion:
Code:
awk -F_ 'a[$1]{print "fastq_to_fasta "a[$1]" "$0; next} {a[$1]=$0}' file

[/quote]
It facing a problem if my input is look the following:
01234_ABC_L1_CDE_PE1.fq
01234_ABC_L1_CDE_PE2.fq
01234_ABC_L2_CDE_PE1.fq
01234_ABC_L2_CDE_PE2.fq
01234_ABC_L3_CDE_PE1.fq
01234_ABC_L3_CDE_PE2.fq
05512_ABC_L1_CDE_PE1.fq
05512_ABC_L1_CDE_PE2.fq
05512_ABC_L2_CDE_PE1.fq
05512_ABC_L2_CDE_PE2.fq
05512_ABC_L3_CDE_PE1.fq
05512_ABC_L3_CDE_PE2.fq

The code can't give the desired output like:
fastq_to_fasta 01234_ABC_L1_CDE_PE1.fq 01234_ABC_L1_CDE_PE2.fq
fastq_to_fasta 01234_ABC_L2_CDE_PE1.fq 01234_ABC_L2_CDE_PE2.fq
fastq_to_fasta 01234_ABC_L3_CDE_PE1.fq 01234_ABC_L3_CDE_PE2.fq
fastq_to_fasta 05512_ABC_L1_CDE_PE1.fq 01234_ABC_L1_CDE_PE2.fq
fastq_to_fasta 05512_ABC_L2_CDE_PE1.fq 01234_ABC_L2_CDE_PE2.fq
fastq_to_fasta 05512_ABC_L3_CDE_PE1.fq 01234_ABC_L3_CDE_PE2.fq

Unfortunately, the code give me another result Smilie
Franklin52, do you have any better idea to get my desired output result?
Actually I got try a way like this:
Code:
awk '/PE1/{print $_}' file_name > file_name.txt
awk '/PE2/{print $_}' file_name > file_name2.txt
paste -d ' ' file_name.txt file_name2.txt > file_name.output.txt

At last, I vi and add the "fastq_to_fasta" inside file_name.output.txt one line by one lineSmilie
It seem like quite troublesome and wasting time Smilie
I think it should got faster way. Just I still can't get itSmilie
Franklin52, thanks again for your help and sorry if bring you any inconvenience.
# 9  
Old 10-12-2009
Code:
awk '{a = $0; getline; print "fastq_to_fasta " a " " $0}' file

# 10  
Old 10-12-2009
That's what you want ?
Code:
# cat file
01234_ABC_L1_CDE_PE1.fq
01234_ABC_L1_CDE_PE2.fq
01234_ABC_L2_CDE_PE1.fq
01234_ABC_L2_CDE_PE2.fq
01234_ABC_L3_CDE_PE1.fq
01234_ABC_L3_CDE_PE2.fq
05512_ABC_L1_CDE_PE1.fq
05512_ABC_L1_CDE_PE2.fq
05512_ABC_L2_CDE_PE1.fq
05512_ABC_L2_CDE_PE2.fq
05512_ABC_L3_CDE_PE1.fq
05512_ABC_L3_CDE_PE2.fq
# awk 'NR%2{printf "fastq_to_fasta" FS $0 FS;next}1' file
fastq_to_fasta 01234_ABC_L1_CDE_PE1.fq 01234_ABC_L1_CDE_PE2.fq
fastq_to_fasta 01234_ABC_L2_CDE_PE1.fq 01234_ABC_L2_CDE_PE2.fq
fastq_to_fasta 01234_ABC_L3_CDE_PE1.fq 01234_ABC_L3_CDE_PE2.fq
fastq_to_fasta 05512_ABC_L1_CDE_PE1.fq 05512_ABC_L1_CDE_PE2.fq
fastq_to_fasta 05512_ABC_L2_CDE_PE1.fq 05512_ABC_L2_CDE_PE2.fq
fastq_to_fasta 05512_ABC_L3_CDE_PE1.fq 05512_ABC_L3_CDE_PE2.fq

# 11  
Old 10-12-2009
thanks a lot, danmeroSmilie
Your code work excellent and solve my trouble nice.
Can you roughly explain the reason of your code?
Thanks again.

Previous Thread | Next Thread
Test Your Knowledge in Computers #772
Difficulty: Medium
An arcade system board is a dedicated computer system created for the purpose of running video arcade games.
True or False?

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Execution of compressed program

I need UNIX scripts for polling, Uncompressing files and moving files between directory. Also trying to save file paths and any other variables in an independent file (.env) and use these at runtime by executing this file in the main script. (3 Replies)
Discussion started by: new2script
3 Replies

2. Programming

Help with C++ program execution.

//Find the root of the equation (x^2)-2 by bisection method. #include<iostream> using namespace std; double a,x; double f(double x) { return ((x*x)-2); } //Suppose the function is (x*x)-2. void calcx(double a1,double b1) { x =... (2 Replies)
Discussion started by: poonam.gaigole
2 Replies

3. Programming

Debugging Program during execution

I have made use of 'valgrind' and -finstrument-functions compiler option for debugging / analyzing code. Both the options lets us know the line / file being executed to some extent. Is there a generic way that lets program dump the file:line it is getting executed dumped to a log file during... (3 Replies)
Discussion started by: uunniixx
3 Replies

4. Programming

A program to trace execution of another program

Hi, I wanted to know if i can write a program using switches and signals, etc to trace execution of other unix program which calls c program internally. If yes how? If not with signals and switches then are there any other methods apart from debugging with gdb/dbx. (3 Replies)
Discussion started by: jiten_hegde
3 Replies

5. Shell Programming and Scripting

Problem while execution of second set of commands

Hi, I have a shell script with code . perf.env cd $QRY_DIR for SHELL_FILE in sql1 do export SNAME=$SHELL_FILE ${SCRIPT_DIR}/perf_qry.sh ${SPOOL_DIR} ${DB_ENVNAME} ${NAME} & RC=$(expr ${RC:-0} + $? ) sleep 60 if then echo sysdate>test1 echo query1.txt>>test1 grep -i... (6 Replies)
Discussion started by: ran16
6 Replies

6. Shell Programming and Scripting

Problem while execution of second set of commands

Hi, I have a shell script with code . perf.env cd $QRY_DIR for SHELL_FILE in sql1 do export SNAME=$SHELL_FILE ${SCRIPT_DIR}/perf_qry.sh ${SPOOL_DIR} ${DB_ENVNAME} ${NAME} & RC=$(expr ${RC:-0} + $? ) sleep 60 if then echo sysdate>test1 echo query1.txt>>test1 grep -i... (0 Replies)
Discussion started by: ran16
0 Replies

7. UNIX for Dummies Questions & Answers

multifile c program compilation and execution

i am using unix os and my program is divided in two text files .:):) how to compile and make one executable file, using unix command. (1 Reply)
Discussion started by: alokmishra8
1 Replies

8. Shell Programming and Scripting

echo just 1 line before execution/set +-x

Suppose that you want to mostly not echo commands inside your script during execution (e.g. to not bog the user down with details that they do not care about) but that there is the occaisional script line that you would like to echo before you execute it. Is there an elegant way to achieve this?... (3 Replies)
Discussion started by: fabulous2
3 Replies

9. UNIX for Dummies Questions & Answers

Set User ID on execution mode.

I have a directory. To this directory, for Group bits combination, it is showing as 's'. Which I found out, it means "Set User ID on execution mode". Within this directory I am not able to create subfolder. Does it mean, only the Owner of this directory will be able to create subdirectories &... (5 Replies)
Discussion started by: videsh77
5 Replies

10. UNIX for Dummies Questions & Answers

Question on Set User ID on Execution

I want group to run one of my unix script as me . I when the script is run it should have my permission's not the group . I tried this : 1.Have a file called y.ksh cat y.ksh echo $LOGNAME >ak_test 2.Output file has this permission -rwx------ ak_test 3.Then I chnaged... (7 Replies)
Discussion started by: akrathi
7 Replies

Featured Tech Videos