Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
# A first example of 'for loop' to iterate a set of commands over a list of files
SamFilesCount=$(ls *.sam | wc -l);
if [[ $SamFilesCount -eq 0 ]]
then
echo " Warning: there are no .sam files to process in this directory!"
exit;
fi
#!/bin/bash
# A mock script, with at least a nice error
REFERENCE='/db/genome.fasta'
for INPUT in *.fastq;
do
fastx_trimmer -i $INPUT -l 90 -Q 33 -o trimmed_${INPUT}
bwa mem $REFERENCE trimmed_${INPUT} > ${IPUT}.sam
samtools view -bS ${INPUT}.sam > ${INPUT}.bam
#!/bin/bash
# Make the script "exit" when a command fails, or a variable is mistyped
set -euo pipefail
# Make the scrip "exit" if the shell expansion (*.fastq) fails
shopt -s failglob
# Check if at least a parameter was passed
if [[ $# == 0 ]]
#!/bin/bash
echo "Total arguments: $#";
echo "-----------------------------------";
echo "Your first argument: $1";
echo "Your second argument: $2";
echo "Your third argument: $3";
@telatin
telatin / depth.txt
Last active March 13, 2018 18:52
Example of "samtools depth -a {FILE.bam}" output
NC_000913 1 81
NC_000913 2 85
NC_000913 3 87
NC_000913 4 91
NC_000913 5 91
NC_000913 6 94
NC_000913 7 95
NC_000913 8 101
NC_000913 9 103
NC_000913 10 108
@telatin
telatin / bedtools_genomecov.txt
Last active March 13, 2018 19:00
Example of "bedtools genomecov -bga" output:
NC_000913 0 1 81
NC_000913 1 2 85
NC_000913 2 3 87
NC_000913 3 5 91
NC_000913 5 16 94
NC_000913 16 17 95
NC_000913 17 18 101
NC_000913 18 19 103
NC_000913 19 20 108
NC_000913 10 11 113
@telatin
telatin / person.xml
Created March 13, 2018 19:11
Example XML
<person>
<name>Andrea</name>
<surname>Telatin</surname>
<hobbies>Hiking</hobbies>
<hobbies>Cooking</hobbies>
<hobbies>Graphic Design</hobbies>
</person>
@telatin
telatin / person2.xml
Created March 13, 2018 19:12
Another XML example
<person>
<name>Andrea</name>
<surname>Telatin</surname>
<hobbies>
<hobby>Hiking</hobby>
<hobby>Cooking</hobby>
<hobby>Graphic Design</hobby>
</hobbies>
</person>
@telatin
telatin / person3.xml
Created March 13, 2018 19:13
XML example
<hobbies>
<hobby order="1">Hiking</hobby>
<hobby order="2">Cooking</hobby>
<hobby order="3">Graphic Design</hobby>
</hobbies>
@telatin
telatin / pubmed.xml
Created March 13, 2018 19:14
Example XML from PubMed
<PubmedArticle>
<MedlineCitation Status="In-Data-Review" Owner="NLM">
<PMID Version="1">29079838</PMID>
<DateCreated>
<Year>2017</Year>
<Month>10</Month>
<Day>28</Day>
</DateCreated>
<Article PubModel="Electronic">
<Journal>