LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 02-05-2012, 09:12 PM   #1
sready
LQ Newbie
 
Registered: Feb 2012
Posts: 2

Rep: Reputation: Disabled
Re-naming and using user input files in bash script


I am trying to use a user provided input file, run it through a program, and rename the output file. I then want to be able to reference the renamed output later on in the program. I am sure it is an easy fix, but I am brand new to writing scripts and internet searches haven't given me anything. Any help would be greatly appreciated. Here is a sample of the code:

#run user input file through program and rename input_trimmed

/usr/local/bin/prinseq-lite.pl -fasta $1 -min_len 150 -out_good $1_trimmed

#run the input_trimmed file through program and rename input_blast.tab
blastx -query $1_trimmed.fasta -db xtrop.protein.faa -out $1_blast.tab -evalue .000001 -outfmt 6 -num_descriptions 1 -num_alignments 1 -num_threads 8

A=$(grep -c ">" $1)
B=$(grep -c ">" $1_trimmed)
C=$($B/$A)
D=$(wc -l $1_blast.tab)
E=$($D/$B)
F=$(sed 's:.*\tgi|\([0-9]*\).*:\1:'$1 _blast.tab | sort | uniq | wc -l)

echo "# and % of sequences in $1: $A"
echo "# and % of $1 sequences in $1_trimmed: $B , $C"
echo "Sensitivity: $E"
echo "# of unique hits: $F"
 
Old 02-05-2012, 10:05 PM   #2
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 10,007

Rep: Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191
You have listed your requirements and shown code but give no indication of what issues you are facing?
What exactly needs to be fixed and if any, what errors are you receiving?
 
Old 02-05-2012, 10:30 PM   #3
sready
LQ Newbie
 
Registered: Feb 2012
Posts: 2

Original Poster
Rep: Reputation: Disabled
When the script is run, it tells me that input_trimmed is not a valid name, no such file or directory. The user input file is designated $1. Apparently the renaming is not being done correctly because it simply ends up creating a file name _trimmed instead of input_trimmed, and a file named Blast.tab instead of input_blast.tab. What do I have to do to make the renaming effective and carry through the entire script?
 
Old 02-05-2012, 11:37 PM   #4
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 10,007

Rep: Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191
Your error would seem to indicate that /usr/local/bin/prinseq-lite.pl does not create a file if it does not already exist.
Try creating it prior to the call.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Collect User Input in a Bash Shell Script LXer Syndicated Linux News 0 02-01-2011 09:30 AM
Bash script predefined user input loopstr Programming 6 08-10-2009 01:10 PM
calling user input in bash script dbmacartney Linux - General 3 05-19-2008 06:55 AM
mask user input in a bash script PlatinumRik Linux - Software 1 06-15-2004 10:06 AM
User input using a BASH script... causticmtl Programming 5 07-13-2003 09:59 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:48 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration