# Path: snakemakelib/bio/ngs/align/star.py
# class Star(Results):
#     """Star: container class for star results"""
#     _keys = ['align']
# 
#     def __init__(self, *args, **kw):
#         self['align'] = None
#         super(Star, self).__init__(*args, **kw)
# 
#     def _collect_results(self):
#         smllogger.info("collecting results")
#         df = None
#         for (f, s) in zip(self._inputfiles, self._samples):
#             smllogger.debug("Reading input file {f} for sample {s}".format(f=f, s=s))
#             df_tmp = pd.read_table(f, sep="|",
#                                    names=["name", "value"],
#                                    engine="python", skiprows=[7, 22, 27])
#             d = {trim_header(x, underscore=True, percent=True): recast(y)
#                  for (x, y) in zip(df_tmp["name"], df_tmp["value"])}
#             if df is None:
#                 df = pd.DataFrame(data=d, index=pd.Index([s], name="Sample"))
#             else:
#                 df = df.append(pd.DataFrame(data=d, index=pd.Index([s], name="Sample")))
#         df['mismatch_sum'] = df['Mismatch_rate_per_base__PCT'] +\
#             df['Deletion_rate_per_base'] + df['Insertion_rate_per_base']
#         df['PCT_of_reads_unmapped'] = df['PCT_of_reads_unmapped:_other'] +\
#             df['PCT_of_reads_unmapped:_too_many_mismatches'] +\
#             df['PCT_of_reads_unmapped:_too_short']
#         self['align'] = df


import unittest
import io
from snakemakelib.bio.ngs.align.star import Star
                          Number of input reads |       4699845
                      Average input read length |       202
                                    UNIQUE READS:
                   Uniquely mapped reads number |       4011114
                        Uniquely mapped reads % |       85.35%
                          Average mapped length |       198.26
                       Number of splices: Total |       1452777
            Number of splices: Annotated (sjdb) |       1424534
                       Number of splices: GT/AG |       1429760
                       Number of splices: GC/AG |       12299
                       Number of splices: AT/AC |       1528
               Number of splices: Non-canonical |       9190
                      Mismatch rate per base, % |       0.70%
                         Deletion rate per base |       0.02%
                        Deletion average length |       1.76
                        Insertion rate per base |       0.01%
                       Insertion average length |       1.46
                             MULTI-MAPPING READS:
        Number of reads mapped to multiple loci |       267393
             % of reads mapped to multiple loci |       5.69%
        Number of reads mapped to too many loci |       7530
             % of reads mapped to too many loci |       0.16%
                                  UNMAPPED READS:
       % of reads unmapped: too many mismatches |       0.00%
                 % of reads unmapped: too short |       8.73%
                     % of reads unmapped: other |       0.08%
"""
        self.f = io.StringIO(self.data)

    def test_collect_results(self):

# Path: snakemakelib/bio/ngs/align/star.py
# class Star(Results):
#     """Star: container class for star results"""
#     _keys = ['align']
# 
#     def __init__(self, *args, **kw):
#         self['align'] = None
#         super(Star, self).__init__(*args, **kw)
# 
#     def _collect_results(self):
#         smllogger.info("collecting results")
#         df = None
#         for (f, s) in zip(self._inputfiles, self._samples):
#             smllogger.debug("Reading input file {f} for sample {s}".format(f=f, s=s))
#             df_tmp = pd.read_table(f, sep="|",
#                                    names=["name", "value"],
#                                    engine="python", skiprows=[7, 22, 27])
#             d = {trim_header(x, underscore=True, percent=True): recast(y)
#                  for (x, y) in zip(df_tmp["name"], df_tmp["value"])}
#             if df is None:
#                 df = pd.DataFrame(data=d, index=pd.Index([s], name="Sample"))
#             else:
#                 df = df.append(pd.DataFrame(data=d, index=pd.Index([s], name="Sample")))
#         df['mismatch_sum'] = df['Mismatch_rate_per_base__PCT'] +\
#             df['Deletion_rate_per_base'] + df['Insertion_rate_per_base']
#         df['PCT_of_reads_unmapped'] = df['PCT_of_reads_unmapped:_other'] +\
#             df['PCT_of_reads_unmapped:_too_many_mismatches'] +\
#             df['PCT_of_reads_unmapped:_too_short']
#         self['align'] = df


# Path: snakemakelib/bio/ngs/tests/test_star.py
import unittest
import io
from snakemakelib.bio.ngs.align.star import Star

                          Number of input reads |       4699845
                      Average input read length |       202
                                    UNIQUE READS:
                   Uniquely mapped reads number |       4011114
                        Uniquely mapped reads % |       85.35%
                          Average mapped length |       198.26
                       Number of splices: Total |       1452777
            Number of splices: Annotated (sjdb) |       1424534
                       Number of splices: GT/AG |       1429760
                       Number of splices: GC/AG |       12299
                       Number of splices: AT/AC |       1528
               Number of splices: Non-canonical |       9190
                      Mismatch rate per base, % |       0.70%
                         Deletion rate per base |       0.02%
                        Deletion average length |       1.76
                        Insertion rate per base |       0.01%
                       Insertion average length |       1.46
                             MULTI-MAPPING READS:
        Number of reads mapped to multiple loci |       267393
             % of reads mapped to multiple loci |       5.69%
        Number of reads mapped to too many loci |       7530
             % of reads mapped to too many loci |       0.16%
                                  UNMAPPED READS:
       % of reads unmapped: too many mismatches |       0.00%
                 % of reads unmapped: too short |       8.73%
                     % of reads unmapped: other |       0.08%
"""
        self.f = io.StringIO(self.data)

    def test_collect_results(self):

        st = Star([(self.f, 'bar')])