pwd to mamba createNarrative thread: “You just logged in. Let’s trace what you’d actually do in the first hour of a new project.”
pwd # print working directory
ls # what's here?
ls -lh # sizes, permissions, dates
ls -lh ~/ # same for home
cd data/ # move around
cd .. # go up
cd ~ # go home
Key point: absolute vs relative paths, ~ shortcut.
mkdir project1
mkdir project1/data project1/results
touch project1/README.txt
cp somefile.txt project1/data/
mv project1/data/somefile.txt project1/data/input.txt
rm project1/README.txt
Key point: filesystem is a tree; build it intentionally from day one.
ls *.fq # wildcard matching
ls *.fq | wc -l # how many FASTQ files?
ls *.tsv >> file_list.txt # append to a log
Key point: | chains commands; > writes (overwrites!), >> appends. Check with ls before acting on wildcards.
head -n 5 genes.tsv
tail -n 20 genes.tsv
less genes.tsv # q to quit, / to search
wc -l genes.tsv # line count
Then filter rows:
grep "protein_coding" genes.tsv # lines matching pattern
grep -c "chr1" genes.tsv # count matches
grep -i "brca" genes.tsv # case-insensitive
awk '$3 > 10000' genes.tsv # numeric filter on column 3
Key point: grep for rows, awk for math/numeric conditions — chain them with pipes.
curl -L -o genes.tsv https://example.org/genes.tsv
head -n 3 genes.tsv # check the header
Extract and reshape columns:
cut -f1,3 genes.tsv # columns 1 and 3 (tab-delimited)
cut -d',' -f2 genes.csv # column 2 from a CSV
cut -f1,3 genes.tsv | head -n 5 # preview the extraction
Sort the results:
sort genes.tsv # alphabetical on column 1
sort -k2,2 genes.tsv # sort by column 2
sort -k3,3n genes.tsv # numeric sort on column 3
sort -k3,3nr genes.tsv # reverse numeric (largest first)
sort -u genes.tsv # unique lines only
cut -f1 genes.tsv | sort -u | wc -l # count unique values in column 1
Key point: cut selects columns, sort orders rows — together they are your quickest path from a raw table to a meaningful summary.
mamba? (1 min — concept only)Problem: bioinformatics tools conflict. Tool A needs Python 3.8, Tool B needs 3.11. Solution: isolated environments.
mamba create (3 min)mamba search samtools # what versions exist?
mamba create --name myproject samtools=1.21
mamba activate myproject
samtools --version # confirm it's live
mamba list # what's installed?
mamba env list # all environments
mamba install fastqc=0.12.1 # add a package
mamba deactivate
Key point: always name the version. The environment is a directory — activate just prepends its bin/ to $PATH.
Bonus line:
mamba env export --from-history > myproject.yml # reproducibility
pwd/ls/cd → mkdir/cp/mv/rm → wildcards+pipes → head/grep/awk → curl+cut+sort → mamba
where am I structure pattern matching row filtering column work install tools
Everything feeds into everything else: you curl a table, cut the columns you need, sort by a numeric field, grep for hits — all with the tool you installed via mamba.