Skip to content

Latest commit

 

History

History
104 lines (81 loc) · 2.59 KB

Basic-Unix-Commands_Practical-Exerciese.md

File metadata and controls

104 lines (81 loc) · 2.59 KB
title author date
Basic Unix Commands
Quynh Nhu Nguyen
May 2nd 2023

BASIC UNIX COMMANDS: PRACTICAL EXERCISES

How many chromosomes are there in the genome?

$ grep ">" apple.genome | wc -l

# Or
$ grep -c ">" apple.genome

How many genes and transcript variants?

# Gene names is listed in 1st column, Transcript variants is listed in 2nd column 
$ cut -f1 apple.genes | uniq | wc -l
$ cut -f2 apple.genes | more | wc -l #Eevery variant was independently, because indeed the file contains only one line for each variant of a gene.

# Or
$ cut -f1 apple-genes | sort -u | wc -l
$ cut -f2 apple-genes | sort -u | wc -l

How many genes have a single variants?

$ cut -f1 apple.genes | uniq -c | grep -c " 1 "

How many genes have multiple variants?

$ cut -f1 apple.genes | uniq -c | grep -v " 1 " | wc -l

How many genes are there on the ‘+’ strand?

$ cut -f1,4 apple.genes | sort | uniq -c | grep "+" | wc -l
# Or
$ cut -f1,4 apple.genes | grep "+" | uniq | wc -l

## How many genes are there on the ‘-’ strand?
```bash
$ cut -f1,4 apple.genes | sort | uniq -c | grep "-" | wc -l
# Or
$ cut -f1,4 apple.genes | grep "-" | uniq | wc -l

How many genes are there on chromosome chr1, chr2, ch3?

cut -f1,3 apple.genes | sort -u | cut -f2 | sort | uniq -c

# Or
$ cut -f1,3 apple.genes | grep "chr1" | sort -u | wc -l

$ cut -f1,3 apple.genes | grep "chr2" | sort -u | wc -l

$ cut -f1,3 apple.genes | grep "chr3" | sort -u | wc -l

How many transcripts are there on chr1, chr2, chr3?

cut -f2,3 apple.genes | sort -u | cut -f2 | sort | uniq -c

# Or
$ cut -f2,3 apple.genes | grep -c "chr1"

$ cut -f2,3 apple.genes | grep -c "chr2"

$ cut -f2,3 apple.genes | grep -c "chr3"

What plant systems contain a Smell gene?

$ grep Smell */*.genes # give us all the lines that contain somewhere within the line, the word smell.

What genes are in common between toy apple and toy pear?

$ cut -f1 apple/apple.genes | sort -u > applegenes

$ cut -f1 pear/pear.genes | sort -u > peargenes

$ comm -1 -2 applegenes peargenes | wc -l

# Or
$ cat applegenes peargenes | sort | uniq -c | grep -v " 1 " | wc -l

What genes are specific to each?

# Genes are specific to the apple species
$ comm -2 -3 applegenes peargenes 

# Genes are specific to the pear species
$ comm -1 -3 applegenes peargenes 

How many gene are in commnon to all three conditions?

cut -f1 apple.conditionC | sort -u > sortC
comm -1 -2 apple.conditionA apple.conditionB > sortAB
comm -1 -2 sortAB sortC | wc -l