-
Notifications
You must be signed in to change notification settings - Fork 1
Command Line Techniques
When developing a script it can be very help to slim down the time you spend typing in the same thing over and over and over and over and over and over and over and over again, which gets to be frustratingly boring! However, by using these secret shortcuts you'll really slim down the time you will have to spend doing all that boring stuff, PLUS it will make you feel like a computer wizard. It will seem like magic to onlookers, who just might say "Wait! what the heck did you just do there?". So give it a try! You might like it.
export S=/home/mcsimenc/scripts/apple-project/quant-snp-matrix.py
alias s='vim $S'
This is how I do it in Python. Super simple, and can save you from frustration if you forget what you wrote a script for. Another line could be added for optional flags if you have any.
args = sys.argv
if len(args) < 2 or '-h' in args:
print('''
usage:
quant-snp-matrix.py <Psalmon> <STsalmon> <STmap> <Tsalmon> <Tmap>
description:
merges expression and vcf data into single table
''', file=sys.stderr)
sys.exit()
When I was working on the script from #2, I did this to make trying it out easier,
export Psalmon=/home/mcsimenc/home2data/apple-pear/reference/MalusDomesticaAnnotation.PhytozomeV12/quantitation/salmon_output
export STsalmon=/home/mcsimenc/home2data/apple-pear/hiseq.huck.psu.edu/StringTieAssemblies/masked/salmon_quant/salmon_output
export STmap=/home/mcsimenc/home2data/apple-pear/hiseq.huck.psu.edu/StringTieAssemblies/masked/stringtie2phytozome.map
Then when you want to test the script you can simply do this,
$S $Psalmon $STsalmon $STmap
and if there was a bug, editing was as simple as
s
saves a lot of time.
4. Make environment variables of directories you currently work in and files you often use. For example, the paths to the reference genomes we're working on, which we need for many programs. MG1 for Malus domestica genome version 1
export A=/home/mcsimenc/home2data/apple-pear/hiseq.huck.psu.edu
export MG1=/home/mcsimenc/home2data/apple-pear/reference/reference_genome1/Mdomestica_196_v1.0.fa
export MG2=/home/mcsimenc/home2data/apple-pear/reference/reference_genome2/GDDH13_1-1_formatted.fasta
then you have shortcuts like this,
cd $A
cp $A/matt/test/newfile.txt .
ln -s $MG1
then you just have to load them if you're going to be working on that project,
source APPLE