#! /usr/bin/env python

"""
runs the manual tests without the need to build and install
"""

import os
import sys
import shutil
import logging

from collections import OrderedDict

sys.path.insert(0, "..")

import tfasta

if __name__ == "__main__":

  logging.basicConfig(level=logging.INFO)

  logging.info("%%%%%%%%%%%%%%%%%%%% testing %%%%%%%%%%%%%%%%%%%%")

  # if os.path.exists('output'):
  #   logging.info("Removing 'output' directory.")
  #   shutil.rmtree('output')

  # logging.info("Running _chemfigit()")
  # texgentest._texgentest.main()

  
  filename = "short-extended.fas"
  print "\n".join(open(filename).read().splitlines()[:10])
  fasta_iterator = tfasta.fasta_parser(filename)
  f = fasta_iterator.next()
  print f['name']
  print f['sequence'][:60]
  f = fasta_iterator.next()
  print f['name']

  print

  import tfasta
  fast = tfasta.fasta_parser("cytb.fas",
                             template=tfasta.T_NR)
  f = fast.next()
  print f['gi']
  print f['accession']
  print f['description']
  print f['source']
  print f['sequence'][:60]


  print
  name = "OVAX_CHICK GENE X PROTEIN N-Term"
  seq = """
        QIKDLLVSSSTDLDTTLVLVNAIYFKGMWK
        afnaedtrempfhvtkqeskpvqmmcmnnsfnvatlpae
        KMKILELPFASGDLSMLV
        """
  print tfasta.make_fasta(name, seq, width=50)


  print
  od = OrderedDict({ "First 10": "QIKDLLVSSS",
                     "Second 10": "tdldttlvlv" })
  print tfasta.make_fasta_from_dict(od)
