Find the answer to your Linux question:
Results 1 to 6 of 6
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    Running Multiple Lines of Code in Succession

    Hey guys,

    I'm using a program this summer which take a DNA sequence and splits it up, looks at the sequence and inherent patterns then outputs a probability of a certain entity existing within the sequence.

    I have a few sequence files, and this program can compute predictions based on 20 different models, which are increasingly more stringent.

    It is useful to predict with all 20 models and see where certain cutoffs occur, but it is a pain to manually enter a line of code, then wait the 5-6 minutes for the predictions to run, then go back, edit the line of code, and increase the model number by 1.

    Is there a way where I can enter in all of the lines of code I want to run, and each line of code will run once the one before it has finished?

    For example

    Command 1 + Command 2 + Command 3 + Command 4 .... Command 20

    >>> RUN <<<

    Command 1 Finished
    Starting Command 2
    Command 2 Finished
    Starting command 3


    >>>FINISHED ALL<<<

    Excuse my lack of technicality -- I'm brand new to linux and just getting these programs to install was a big hassle for me.

    Thanks a bunch for any help!


  2. #2
    Linux Guru
    Join Date
    Oct 2007
    Tucson AZ
    Write a script with the commands you want sequentially. If you are not familiar with programming, the first thing you would need to do is post the programming language you need/want to use so that someone familiar with it can assist you.

  3. #3
    Linux Newbie theNbomr's Avatar
    Join Date
    May 2007
    BC Canada
    for i in $(seq 1 20); do
       command $i
    Stuff happens. Then stays happened.

  4. $spacer_open
  5. #4
    Linux User
    Join Date
    Nov 2008
    Tokyo, Japan
    This is a nice easy problem.
    The Linux command line is also a programming language called "Bash." So you can write your commands into an ordinary text file, and tell the command line to execute every command in the file. Say your command file is "". To tell the command line to execute each line in the file, write a dot, then the full path to the file like this:
    . ./
    # or equivalently:
    . $PWD/
    Or you could also use the built-in command "source"
    I highly recommend you learn everything you can about the Bash language, Google for introductions, tutorials, tricks.
    Here is an example with conditional execution:
    printf 'What is your name? ';
    read Name;
    if [ "${Name}" == 'Dan' -o "${Name}" == 'Bob' ];
        echo "Hey, ${Name}, you're my hero."
        printf "Hello ${Name}, nice to meet you.\n";
    printf "Today's date is $(date)\n";
    The file extension for Bash source code is ".sh". Since making scripts is such a common task in Linux, most editors will automatically enable syntax coloring and automatic indentation when you start editing any file with the extension ".sh". I recommend learning Emacs or Vim. In my own experience, Vim is easier to learn once you get the basics, but the basics aren't intuitive and take some getting-used-to.
    Last edited by ramin.honary; 07-03-2013 at 05:26 AM.

  6. #5
    Awesome, thanks you guys for all of your help -- I'll be switching over to my Linux OS soon to test this, and I'll let you know how it goes.

    Thanks again!

  7. #6

    Writing the script with the command on each line worked beautifully.

    Here's what I ended up with

    #03/07/2013 -- miRPara Predictions Script
    #--- Nick Ostan ---
    #Generate Parameter File from Fasta Sequences
    perl -p 60 -f 100 -o 99 "/home/nick/Downloads/miRPara6.2/sequences/FILE_1.fa"
    perl -p 60 -f 100 -o 99 "/home/nick/Downloads/miRPara6.2/sequences/FILE_2.fa"
    perl -p 60 -f 100 -o 99 "/home/nick/Downloads/miRPara6.2/sequences/FILE_3.fa"
    perl -p 60 -f 100 -o 99 "/home/nick/Downloads/miRPara6.2/sequences/FILE_4.fa"
    perl -p 60 -f 100 -o 99 "/home/nick/Downloads/miRPara6.2/sequences/FILE_5.fa"
    #Generate SVM Probability and Mature Sequence Predictions from .pmt File
    The code goes on here for a long time but its just repeats of random stuff
    Then I put the script in the same folder as my perl .pl file, and executed

    . ./
    Works beautifully. Takes a bit of a altering small things cause for some reason I got a bunch of error messages at the beginning but I couldn't be more pleased.

    If I work with Linux more often I'll be sure to learn this BASH programming language!


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts