new_contents: """This directory is setup with configurations to run the main functional test.
  
  It exercises a full analysis pipeline on a smaller subset of data.
  """
  import os
  import subprocess
  import unittest
  import shutil
  import contextlib
  import collections
  import functools
  
  from nose import SkipTest
  from nose.plugins.attrib import attr
  import yaml
  
  
  @contextlib.contextmanager
  def make_workdir():
      remove_old_dir = True
      dirname = os.path.join(os.path.dirname(__file__), "test_automated_output")
      if remove_old_dir:
          if os.path.exists(dirname):
              shutil.rmtree(dirname)
          os.makedirs(dirname)
      orig_dir = os.getcwd()
      try:
          os.chdir(dirname)
          yield dirname
      finally:
          os.chdir(orig_dir)
  
  def expected_failure(test):
      """Small decorator to mark tests as expected failure.
      Useful for tests that are work-in-progress.
      """
      @functools.wraps(test)
      def inner(*args, **kwargs):
          try:
              test(*args, **kwargs)
          except Exception:
              raise SkipTest
          else:
              raise AssertionError('Failure expected')
      return inner
  
  class AutomatedAnalysisTest(unittest.TestCase):
      """Setup a full automated analysis and run the pipeline.
      """
      def setUp(self):
          self.data_dir = os.path.join(os.path.dirname(__file__), "data", "automated")
  
      def _install_test_files(self, data_dir):
          """Download required sequence and reference files.
          """
          #       self._download_to_dir(url, dirname)
  
      def _download_to_dir(self, url, dirname):
          print dirname
          cl = ["wget", url]
          subprocess.check_call(cl)
          cl = ["tar", "-xzvpf", os.path.basename(url)]
          subprocess.check_call(cl)
          shutil.move(os.path.basename(dirname), dirname)
          os.remove(os.path.basename(url))
  
      @attr(complete=True)
      @attr(cluster=True)
      def test_srnaseq_star(self):
          """Run cluster analysis
          """
          # self._install_test_files(self.data_dir)
          with make_workdir() as workdir:
              cl = ["seqcluster",
                    "cluster",
                    "-m", "../../data/examples/cluster/seqs.ma",
                    "-a", "../../data/examples/clusters/seqs.bam",
                    "-gtf", "../../data/examples/cluster/annotation_red.gtf",
                    "-o", "test_out_res"]
              subprocess.check_call(cl)
  
  
subject: Add automated test inspared in bcbio-nextgen code