Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions homework/homework_2.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ output: pdf_document


\subsection*{Advanced Unix Tools}
Most Unix implementations include a large number of powerful tools and utilities. (Unix has been in development for more than 50 years!). We were only able to scratch the surface in our class time. It will take time to become comfortable with Unix, but as you struggle, you will find yourself learning just by looking at \texttt{man} files and finding solutions on the internet. For this Homework, you will explore several more advanced Unix functions. You can use any resource available to you--classmates, the internet (Google and ChatPGT!), and Dr. Johnson. Ask all the questions you want, just make sure you do the work and you learn!
Most Unix implementations include a large number of powerful tools and utilities. (Unix has been in development for more than 50 years!). We were only able to scratch the surface in our class time. It will take time to become comfortable with Unix, but as you struggle, you will find yourself learning just by looking at \texttt{man} files and finding solutions on the internet. For this Homework, you will explore several more advanced Unix functions. You can use any resource available to you--classmates, the internet (Google and ChatGPT!), and Dr. Johnson. Ask all the questions you want, just make sure you do the work and you learn!

\begin{enumerate}
\item Learn more about tools for downloading files from external servers (e.g., \texttt{scp}, \texttt{ftp}, \texttt{sftp}, \texttt{rsync}), and for to downloading data from webpages (e.g., \texttt{curl}, \texttt{wget}, \texttt{mget}). Use an appropriate function to download the \texttt{homework2.tar.gz} from the homework folder on course GitHub page. Give the code you used to download these data.({\bf Hint:} To download the \texttt{homework2.tar.gz} from GitHub, control/right click on the "View raw" link and copy the location (see image). If you use the URL in the address bar it downloads the .html for the website. Note this picture might be from a different homework and class, but the action is still the same.)
\item Learn more about tools for downloading files from external servers (e.g., \texttt{scp}, \texttt{ftp}, \texttt{sftp}, \texttt{rsync}), and for downloading data from webpages (e.g., \texttt{curl}, \texttt{wget}, \texttt{mget}). Use an appropriate function to download the \texttt{homework2.tar.gz} from the homework folder on course GitHub page. Give the code you used to download these data.({\bf Hint:} To download the \texttt{homework2.tar.gz} from GitHub, control/right click on the "View raw" link and copy the location (see image). If you use the URL in the address bar, it downloads the .html for the website. Note this picture might be from a different homework and class, but the action is still the same.)
\begin{center}\includegraphics[width=0.7\textwidth]{homework2_tarball}\end{center}
\item \label{tar} Learn about the \texttt{tar} function. What is a tarball? How is it different from a .zip file? Download the \texttt{homework2.tar.gz} file from GitHub and unzip the contents, and report that code you used. How effective is the compression for this tarball? After you complete this homework, add your homework files directory and generate a gzipped tarball for all the Homework 1 data plus your answers. Make sure to provide the code you used to generate the tarball for your homework.
\item Research the \texttt{chmod} function. Give short explanation of what this function does, its syntax, and examples when you would use it. Practice \texttt{chmod} by changing the permissions on the `TB\_microbiome\_data.txt' file in the Homework 1 directory from the previous questions. Give examples of the code you used and show that the code works (e.g., use \texttt{ls -l}).
\item The \texttt{grep} function is an extremely powerful tool for search (potentially large) files for patterns and strings. One advantage is that you don't have to open the file to conduct a search! Using the internet, find a short tutorial on the basics of \texttt{grep}, and give the code and results for the following tasks:
\item \label{tar} Learn about the \texttt{tar} function. What is a tarball? How is it different from a .zip file? Download the \texttt{homework2.tar.gz} file from GitHub and unzip the contents, and report the code you used. How effective is the compression for this tarball? After you complete this homework, add your homework files directory and generate a gzipped tarball for all the Homework 1 data plus your answers. Make sure to provide the code you used to generate the tarball for your homework.
\item Research the \texttt{chmod} function. Give a short explanation of what this function does, its syntax, and examples when you would use it. Practice \texttt{chmod} by changing the permissions on the `TB\_microbiome\_data.txt' file in the Homework 1 directory from the previous questions. Give examples of the code you used and show that the code works (e.g., use \texttt{ls -l}).
\item The \texttt{grep} function is an extremely powerful tool for searching (potentially large) files for patterns and strings. One advantage is that you don't have to open the file to conduct a search! Using the internet, find a short tutorial on the basics of \texttt{grep}, and give the code and results for the following tasks:
\begin{enumerate}
\item How many FC receptor genes are present in the `TB\_nanostring.txt' file? (hint: search for `FC' in the file)
\item How many samples (rows) in the `nanostring\_annotation.txt' do not have a co-morbid condition or other risk factor?(i.e., inverse search -- how many rows {\it do not} have a "Yes")
Expand All @@ -24,7 +24,7 @@ Most Unix implementations include a large number of powerful tools and utilities
\end{enumerate}
\item Learn how to use \texttt{less} to display large text files in the terminal using the \texttt{man} help page. Using the "OPTIONS" section of the \texttt{man} page, open the `viral.fasta' file to display so that it does not wrap long lines (default), displays line numbers, and opens at the first occurrence of `coronavirus'. Provide the command you used to open the file in this way. Within \texttt{less}, learn and practice how to scroll forward/backward, scroll forward/backward $n$ lines, jump to the middle or end of the file, and search for text in the document. When would it be advantageous to use \texttt{less} over a tool like Microsoft Word? Ask Dr. Johnson why in Unix \texttt{more} is less and \texttt{less} is more :-).
\item Open a text file in \texttt{vim} and change the file. How do you move to the beginning/end of a line, insert text, copy and paste, delete text and lines? How do you save your file or exit \texttt{vim} with/without saving your result? What are the advantages and disadvantages of \texttt{vim} versus \texttt{less}? In which scenarios would you use each of these?
\item Learn about \texttt{pipes} and \texttt{redirects} in Unix. In which scenarios would you use them, and why are they helpful? describe what the following commands do:
\item Learn about \texttt{pipes} and \texttt{redirects} in Unix. In which scenarios would you use them, and why are they helpful? Describe what the following commands do:
\begin{enumerate}
\item \texttt{ls -l | less}
\item \texttt{ls -l > directory\_contents.txt}
Expand All @@ -34,9 +34,9 @@ Most Unix implementations include a large number of powerful tools and utilities
\item \texttt{ls | wc -l}
\item \texttt{cat file1.txt file2.txt > file3.txt}
\end{enumerate}
You can also us pipes in R! Investigate how to do this and give the code for a great example.
You can also use pipes in R! Investigate how to do this and give the code for a great example.
\item Learn about another Unix command that we have not discussed. Give a short description of this function, when you would use it, its syntax, and give some examples of its use.
\end{enumerate}