#!/usr/bin/env python

# RSD: The reciprocal smallest distance algorithm.
#   Wall, D.P., Fraser, H.B. and Hirsh, A.E. (2003) Detecting putative orthologs, Bioinformatics, 19, 1710-1711.
# Original Author: Dennis P. Wall, Department of Biological Sciences, Stanford University.
# Author: Todd F. DeLuca, Center for Biomedical Informatics, Harvard Medical School
# Contributors: I-Hsien Wu, Computational Biology Initiative, Harvard Medical School

import argparse
import os
import shutil

import rsd


def main():
    # create command line parser for "format" command
    formatDesc = ('Reciprocal smallest distance (RSD) uses BLAST to search for putative orthologs.  ' +
                  'This command formats a FASTA-formatted genome for use with BLAST.  ' +
                  'By default, index names are derived from the name of GENOME and the indexes are placed in the same dir as GENOME.  ' +
                  'If DIR is specified, GENOME is copied to DIR, and indexes are placed in DIR.')
    parser = argparse.ArgumentParser(description=formatDesc)
    parser.add_argument('-d', '--dir', help='Dir where BLAST indexes will be put.  Default: the directory containing GENOME.')
    parser.add_argument('-g', '--genome', required=True, help='FASTA format protein sequence file, with unique ids on each nameline either in the form ">id" or ">namespace|id|...".')
    args = parser.parse_args()

    if args.dir:
        destFasta = rsd.copyFastaArg(args.genome, args.dir)
        rsd.formatFastaArg(destFasta)
    else:
        rsd.formatFastaArg(args.genome)


if __name__ == '__main__':
   main()

   
# last line
