      ,-"-.   ,-"-. ,-"-.   ,-"-. 
     X | | \ / | | X | | \ / | | X 
      \| | |X| | |/ \| | |X| | |/ 
       `-!-' `-!-"   `-!-' `-!-'  
    +-------^------^------^-------+
    |           TF2DNA            |
    |                             |
    | Obtain transcription factor |
    |   DNA binding preferences   |
    |                             |
    |        version 0.31         |
    +-----------------------------+
    By Mario Pujato and Andras Fiser
           (www.fiserlab.org)
	


DESCRIPTION:

TF2DNA is a structure-based method that predicts DNA binding preferences of
  transcription factors (TF) based on the knowledge of its sequence or structure

--------------------------------------------------------------------------------

INDEX

1) Installation and removal
2) TF2DNA program usage and available options
3) Notes
4) Running tests (these also serve as EXAMPLES)
5) Format of the mutations file
6) Using TF2DNA on a computer cluster or computer with multiple processors/cores
7) Adding a NEW protein-DNA complex to the database

--------------------------------------------------------------------------------


1) Installation

  To install first change the paths in the "parameters.txt" file to choose the
    installation directory ("TF2DNA_BIN_DIR" and "TF2DNA_LIB_DIR"). Check for
    writing permissions on the install directories.

  To install run on terminal:
    ./tf2dna_installer -i

  To remove the program type:
    ./tf2dna_installer -r

  The program is modular, with different functionalities or capabilities.

  Full program capabilities are achieved by correctly providing the directories
    pointing to the required external dependencies (within the "parameters.txt"
    file).

  If a dependency is not found, that functionality will be disabled.

  TF2DNA contains some "out-of-the-box" capabilities, such as:

    - Normalize DNA scores and apply cutoffs to define DNA binding sites
    - Generate PWM from DNA sequence and scoring information
    - Generate sequence logos based on DNA sequences or PWMs (white background)


  * Required external dependencies *

  a. To enable generation of Hidden Markov Models (HMM) and HMM-to-HMM alignment
      capabilities, the program "HH-suite" must be correctly installed:
     Below we list the key executables and files needed to properly run "HH-suite":

     HHSUITE executables (ftp://toolkit.genzentrum.lmu.de/pub/HH-suite/):
       'hhsearch', 'hhalign', 'Align.pm', 'hhfilter'

     BLAST executables (ftp://ftp.ncbi.nlm.nih.gov/blast/executables/release/LATEST/):
       'makemat', 'blastpgp'

     PSIPRED executables and files (http://bioinfadmin.cs.ucl.ac.uk/downloads/psipred/):
       'psipass2', 'psipred'
       'weights_p2.dat', 'weights.dat', 'weights.dat2', 'weights.dat3'

     Note: PSIPRED only supports BLAST versions that are pre-BLAST+, therefore be sure
      to install legacy BLAST executables.

  b. To enable model building capabilities, install the following programs:

     VMD executable (http://www.ks.uiuc.edu/Research/vmd/):
       'vmd'

     NAMD executable (http://www.ks.uiuc.edu/Research/namd/):
       'namdx'

     MODELLER executable (https://salilab.org/modeller/download_installation.html):
       'modx.xx'

     "x" replaces the version numbers

  c. Optional functionality to generate sequence logos with transparent background:
     (ImageMagick is a software suite to create, edit, compose, or convert bitmap 
      images)

     IMAGEMAGICK executable (http://www.imagemagick.org/script/download.php):
       'convert'


	
2) TF2DNA program usage and available options

  USAGE: tf2dna [options] <file_name>

  [options]

    INPUTS (see NOTES below)

        -F  Specify FASTA file containing one transcription factor
             sequence. Only the first sequence is processed.
            Outputs Hidden Markov Model of the sequence (*.hhm file).

        -H  Specify a precalculated hidden Markov model file of a TF sequence.
             Must be a valid *.hhm file.
            Outputs a structural model of the sequence, if template is found
             (*.pdb file; this file has the name of the template used appended 
             in the file name).

        -M  Specify model file of the TF-DNA complex structure in PDB format.
            Outputs mutations file for the DNA in the complex (*.mut file).

        -K  Specify a file containing the DNA kmers and their Robertson-
             Varani scores. This file must have the same format as the TF2DNA
             segments output file obtained with the -k option (you can ommit 
             the third field with normalized scores).
            Outputs PWM (*.mat file).

        -U  Specify DNA mutations file (must be in correct format -see point 5).

        -P  Specify a PWM file. Must be in JASPAR format.
            Outputs sequence logo image of binding preferences (*.png file).

    ACTIONS

        -m  Build model of the TF based on best template structure.
            (default if -H option is provided)

        -S  Sample DNA sequences specified in the mutations file.
            Outputs PWM and scored DNA sequences (*.mat and *.pred files).

        -r  Obtain reverse complement of the PWM (it also affects the -w option).

        -t  Make sequence logo background transparent.

    PARAMETERS

        -q  (hhsearch-option) Minimum sequence identity with query.
             (default = 30)

        -n  Minimum number of binding sites returned.
             (default = 30)

        -N  Maximum number of binding sites returned.
             (default = 300)

        -c  Score cutoff to define a DNA segment as a binding site.
             (default = 0.25)

        -a  Overrides "-n" and "-c" options, returning the complete set of 
             DNA segments and their associated scores.

    OUTPUTS

        -o  Specify base name for naming TF2DNA output files.
             (default = base name of provided file)

        -k  Outputs kmers, Robertson-Varani raw and transformed scores to an 
             *.pred file.
             (default if -S option is provided)

        -u  Outputs DNA mutations to an *.mut file.
             (default if -M option is provided)
            This is specially useful to generate a file containing exhaustive
             mutations on the DNA that may be later split into smaller files to
             run serial jobs in a computer cluster or in a computer with 
             multiple processors.

        -s  Saves to disk the mutants generated with the -S option
             (as PDB files).

        -p  Prints PWM to an *.mat file.
             (default if either -S or -K options are provided)

        -w  Print sequence logo of the PWM to an *.png file (PNG format).
             (default if -P option is provided)



3) Notes

  Arguments F, H, M, K and P are exclusive and have precedence in the following
   order: P > K > M > H > F. Meaning that if multiple options are given, the
   options with least precedence are ignored.

  For example, if arguments for K and H are provided, H is ignored and actions
   will apply to the provided kmers file.



4) Running tests (these also serve as EXAMPLES)

    i. Generate hidden Markov model from sequence

       tf2dna -F test/test-MYOG.fasta

       outputs:
         test-MYOG.hhm

   ii. Generate structure model from HMM

       tf2dna -H test/test-MYOG.hhm

       outputs:
         test-MYOG_c117_2QL2.pdb      # Model structure (c117_2QL2 is the template used)
         test-MYOG_c117_2QL2_ali.dat  # Alignment between query and template
         test-MYOG_c117_2QL2_info.dat # Model and alignment information, i.e. %id
         test-MYOG_c117_2QL2_log.dat  # MODELLER log file

  iii. Generate the mutations file for the provided structure

       tf2dna -M test/test-MYOG.pdb

       outputs:
         test-MYOG.mut (see point 5 for details on the format of this file)

   iv.  Generate DNA mutant models and score interfaces from structure
       If a mutations file (with -U) is not provided, then the search is exhaustive

       tf2dna -SM test/test-MYOG.pdb -U test/test-MYOG.mut

       outputs:
         test-MYOG.pred # list of explored DNA segments with their interface scores
         test-MYOG.mat  # Matrix file

    v. Generate sequence logo from matrix file

       tf2dna -wP test/test-MYOG.mat

       outputs:
         test-MYOG.png



5) Format of the mutations file
  You can provide a mutations file including any mutations in the DNA you are
   interested in. The format of the mutations file must be respected.

  Mutations file format:

    m00001 AAAAAAAA 0 7
    m00002 CAAAAAAA 0 7
    m00003 TAAAAAAA 0 7

    -first  field is the name of the resulting mutated model.
    -second field is the mutant sequence to be threaded into the template.
    -thrid  field is the index of the first base pair to consider in the'
      template DNA. The first ocurring base pair in the template file gets an
      index of 0.
    -fourth field is the index of the last base pair to consider in the
      template DNA. The last  ocurring base pair in the template file gets an
      index of k-1
      (k is the length of the sequence in base pairs).


    Notes:
      Please provide entire DNA sequences, covering the totality of the DNA 
       segment in the structure.
      No gaps (-) are allowed in this version of TF2DNA.



6) Using TF2DNA on a computer cluster or computer with multiple processors/cores

  TF2DNA can be easily used for serial jobs on a computer cluster.

  The simplest way is to split the mutations file into smaller files and run as
   separate jobs. For example, if there are 10,000 mutations (lines) in the
   mutations file, we can divide it into 1,000 files containing 10 mutations each
   using the unix "split" command. Each of the 1,000 files can then be
   separately computed (see example "v" above).

  The mutations file can be generated like in example "iv" above.



7) Adding a NEW protein-DNA complex to the database

  Protein-DNA complex structures are saved in the folder "templates_pdb" within
   the set "TF2DNA_LIB_DIR" directory in the parameters file.

  Make sure to clean the PDB file of the new complex to contain only the protein
   of interest and the DNA bases (should have blunt ends!) that are in contact
   with the protein. Note that if more than 9 bases are included, the exhaustive
   search will take a really long time (it's OK if you have proper resources).

  After cleaning, save the new complex PDB file within the "TF2DNA_LIB_DIR/templates_pdb"
   folder.

  The last step (not optional!) is to identify the binding site. For this purpose
   run the program "getBindingSite" installed within "TF2DNA_BIN_DIR".
  The program adds a line at the end of each file inter-DNA_TFpdb.list and 
   inter-Bases_TFpdb.list in the folder "TF2DNA_LIB_DIR/Model", containing the 
   residues in contact with the entire DNA (at the provided distance cutoff) and
   with the DNA bases only.
