Skip to content

Unix II: Some basic commands

Bioinformatics Core Facility Gothenburg edited this page Jan 22, 2019 · 10 revisions

Course: HT17 Unix with applications to next generation sequencing data (SC00025)


Let's practice some commands

First copy files used for exercises:

cp /home/marcela/unix/files/day2.tar .

extract the files in the archive

tar -xvf day2.tar

cat and redirection

Q1. What is the command to use if you were to combine the contents of the file S1.vcf and the file S2.vcf into one new file with the name all.txt ?

Q2. What is the command to use if you want to append to the file all.txt the contents of the file S3.vcf?

grep

Q3. You want to know if the SNP rs17098198 is in the file ADK.snp.vcf. What is the command to use?

Q4. How many header lines (those starting with #) are there in the file ADK.snp.vcf?

Q5. In how many lines does the word PASS (which means the variant passed a set quality filter) occur in the file S1.vcf?

Q6. What files in your directory contains the position 862389? How do you write the command?

cut

Q7. Extract the 4th and 5th fields of the file S2.vcf and save these in a new file. What is the command used?

Q8. Suggest a command to extract the first column from the comma-separated file dat2.txt

sort

Q9. What is the command to sort the file dat2.txt numerically by the numbers in column 2?

Q10. What is the command to sort the lines of the Homo_sapiens.chr10.gtf file, based on the information in the column showing strand +/- ? Save the sorted lines in a new file.

uniq

Q11. See exercise 10. For the exons in the file created, extract the strand column and use it to answer the question: how many exons are on the plus and minus strands, respectively?

find

Q12. Suggest a command to find all files in your directory with the extension .txt, using find.

Q13. When would you prefer to use the above find command instead of the command ls *.txt?

A combination of commands and piping

Q14. Examine again the file Homo_sapiens.chr10.gtf. How many different types of transcripts are there (field 2)? How many lines are annotated lincRNA?

Q15. What is the command to extract the accession codes (like AY156735.1 in the line ">gi|24209941|gb|AY156735.1| HIV-1 clone P2.BCM.RT from USA reverse transcriptase (pol) gene, partial cds") from the file rt.fa?



Created by Tore Samuelsson and Katarina Truvë

Clone this wiki locally