Beispiel #1
0
 def __init__(self, *args, **_):
     GeneralizedPairState.__init__(self, *args)
     self.dp = config.preparers[config.preparer_index][0](constants.window_size)
     self.clf_fname = 'data/clf/{}{}{}.clf'.format(
         PairClassifier.get_name(),
         config.preparers[config.preparer_index][2],
         constants.window_size,
     )
     self.clf = self._get_classifier()
     self.annotations, self.ann_x, self.ann_y = None, None, None
     self.emission_table = None
Beispiel #2
0
 def __init__(self, *args, **_):
     GeneralizedPairState.__init__(self, *args)
     self.dp = config.preparers[config.preparer_index][0](
         constants.window_size)
     self.clf_fname = 'data/clf/{}{}{}.clf'.format(
         PairClassifier.get_name(),
         config.preparers[config.preparer_index][2],
         constants.window_size,
     )
     self.clf = self._get_classifier()
     self.annotations, self.ann_x, self.ann_y = None, None, None
     self.emission_table = None
Beispiel #3
0
 def __init__(self, *args, **kwargs):
     ClassifierState.__init__(self, *args, **kwargs)
     self.dp = self._get_preparer(0)
     if config.same_classifier:
         suffix = ''
     else:
         suffix = '_indel'
     self.clf_fname = 'data/clf/{}{}{}{}.clf'.format(
         PairClassifier.get_name(),
         config.preparers[config.preparer_index][2],
         constants.window_size,
         suffix,
     )
     self.clf = self._get_classifier()
Beispiel #4
0
 def __init__(self, *args, **kwargs):
     ClassifierState.__init__(self, *args, **kwargs)
     self.dp = self._get_preparer(0)
     if config.same_classifier:
         suffix = ''
     else:
         suffix = '_indel'
     self.clf_fname = 'data/clf/{}{}{}{}.clf'.format(
         PairClassifier.get_name(),
         config.preparers[config.preparer_index][2],
         constants.window_size,
         suffix,
     )
     self.clf = self._get_classifier()
Beispiel #5
0
        data = (
            (
                seq_x, pos, create_annotation(ann_x),
                seq_y, pos, create_annotation(ann_y),
            )
            for seq_x in itertools.product('ACGT', repeat=window_size)
            for seq_y in itertools.product('ACGT', repeat=window_size)
            for ann_x in itertools.product('01', repeat=window_size)
            for ann_y in itertools.product('01', repeat=window_size)
        )
    else:
        data = (
            (
                seq_x, pos, create_annotation(ann_x),
                seq_y, pos, create_annotation(ann_y),
            )
            for seq_x in 'ACGT'
            for seq_y in 'ACGT'
            for ann_x in '01'
            for ann_y in '01'
        )

    s = sum(clf.multi_prepare_predict(data))
    return s


if __name__ == '__main__':
    dp = DataPreparer(window_size)
    clf = PairClassifier(dp, filename='data/randomforest1.clf')
    print('Normalization constant:', compute_norm_constant(clf))
Beispiel #6
0
 def _get_classifier(self):
     return PairClassifier(self.dp,
                           filename=self.clf_fname,
                           inverted=config.same_classifier,
                           use_global_classifier=config.same_classifier)