TITLE: Metatranscriptomic screening for genes of interest
AUTHORS: Helena Pound, Steven Wilhelm

[DESCRIPTION]
<div class = "text-blocks"><div class = "text-block">Find genes of interest in assembled metatranscriptomic library using blast.</div></div>

[STEPS]
?. [Establishing Candidates]
Blast assembly against reference database you just created    - e-value can be changed to your preference    - final.txt will produce list of contigs from assembly that had blast hits, to be referred to as "candidates"
?. [Establishing Candidates]
?. [Establishing Candidates]
?. [Establishing Candidates]
Make a database from the list of genes of interest (referred to as the reference.fasta) in command line window.
Protein sequences are required for phylogenetic placement in later steps.
?. [Establishing Candidates]
Extract only the aligned portion of candidate contigs.
- Sometimes, contigs from assembly may be longer than a single gene.  To accurately estimate transcript expression, we want to trim candidates to the exact length of the reference gene, by trimming it according to the start and finish locations of the blast alignment. Custom python script performs this trimming. Script relies on column order, so double-check that your .txt file contains all columns listed in 2.1. If a candidate contig hits to more than one reference sequence, the lowest start point and the highest end point from all hits will be used to capture the entire candidate sequence.
?. [Establishing Candidates]
Custom python script found at https://github.com/Wilhelmlab/general-scripts/blob/master/Pound2019_Extract_aligned.py
?. [Establishing Candidates]
Convert .txt file generated from step 3.1 to a .csv file-Open .txt file in Microsoft Excel and save as .csv
?. [Establishing Candidates]
Import .csv file into CLC Workbench as "sequences in .csv format"
?. [Establishing Candidates]
Sort sequences by length and delete sequences smaller than 150 nucleic acids or personal preference
This length cutoff can be changed based on personal preference.
?. [Establishing Candidates]
Export sequence list as .fasta file and .csv file (named trimmed.fasta/csv or something similar).
?. [Establishing Candidates]
Perform Diamond blastx against NCBI non-redundant database.
-This step is a quality control mechanism to identify sequences that may not be of viral origin. - Diamond is used to for expediting the process (faster than traditional blast)
?. [Establishing Candidates]
Download non-redundant database from NCBI in .fasta format    -rename nonredundant.fasta
?. [Establishing Candidates]
Make diamond database>diamond makedb --in non-redundant.fasta -d non-redundant
?. [Establishing Candidates]
Blast
?. [Establishing Candidates]
Open candidates.txt file and trimmed.csv file in Excel.  Copy sequences from trimmed.csv to a new column in candidates.txt file in excel (make sure sequence names match up).
?. [Establishing Candidates]
Delete sequences that are not viral in origin (refer to diamond blast hit in the candidates.txt file).
Be sure to delete the entire row.
?. [Establishing Candidates]
Create a new .csv file with viral sequences and query frames from candidates.txt file    - 3 columns: sequence name, sequence, query frame
?. [Establishing Candidates]
Sort by query frame. Create a new .csv file for each query frame containing respective sequences
Ex. CandidatesQF+1.csv
?. [Establishing Candidates]
Import each query frame.csv file into CLC workbench as separate sequence lists
?. [Establishing Candidates]
Create new sequence list and combine all query frame sequence lists    - rename "FinalCandidatesNucleicAcid"
?. [Establishing Candidates]
Translate individual query frame sequence list to protein based on the query frame.
?. [Establishing Candidates]
Create new sequence list and combine all protein sequences    - rename "FinalCandidatesProtein"
?. [Establishing Candidates]
Export FinalCandidatesProtein sequence list as a .fasta file