コード例 #1
0
    def parse(self, output):
        """
        Parse anchor output and extract binding regions

        Return and save (in a .json file) a dictionary with binding sites,
        linear motifs and protein length for each protein present in anchor
        output

        :param output: Original text output from Anchor
        :types output: str

        :return: xray_fasta regions per protein
        :rtype: dict
        """

        probs = list()

        for line in output.decode('utf-8').split("\n"):
            # check if the first character is a residue position
            if not line.startswith("#"):
                line = line.strip().split()

                if len(line) > 0:
                    probs.append(float(line[2]))

        if probs:
            return [Prediction(self.tag, probs, self.threshold, self.types)]
コード例 #2
0
ファイル: consensus.py プロジェクト: smoe/interproscan
    def calc_agreement(self, seq, threshold, ptype=None, force_consensus=False):
        """
        Compute agreement from a stack of predictions

        :param seq: amino acid sequence
        :type seq: str
        :param threshold: agreement threshold
        :type threshold: float
        :param ptype: prediction type to consider for agreement
        :type ptype: str
        :param force_consensus: if True consensus computation is computed despite
            single predictors errors
        :type force_consensus: bool
        """
        agreement = [0.0] * len(seq)
        included_predictors = 0

        for prediction in self.predictions_stack:

            if ptype is not None and ptype in prediction.types:
                logging.debug('%s | agreement: included', prediction.method)

                if prediction.has_correct_length(seq, force_consensus):
                    logging.debug('%s | length: OK (%i)', prediction.method, len(seq))

                    included_predictors += 1
                    agreement = map(sum, zip(agreement, prediction.states))
            else:
                logging.debug('%s | agreement: excluded', prediction.method)

        agreement = [summed_states / included_predictors for summed_states in agreement]

        self.prediction = Prediction(self.tag, agreement, threshold)
コード例 #3
0
    def parse(self, output):
        probs = [
            float(line.split()[-1])
            for line in output.decode('utf-8').split("\n")[3:] if line
        ]

        if probs:
            return [Prediction(self.tag, probs, self.threshold, self.types)]
コード例 #4
0
    def parse(self, output):
        probs = list()
        for row in output.decode('utf-8').split("\n"):
            if len(row) > 0 and row[0] != ">":
                probs.append(round(float(row.split()[1]), 4))

        if probs:
            return [Prediction(self.tag, probs, self.threshold, self.types)]
コード例 #5
0
    def parse(self, output):
        probs = list()
        for line in output.decode('utf-8').strip().split("\n"):
            if line[0] != "#":
                line = line.strip().split()
                probs.append(round(float(line[2]), 4))

        if probs:
            return [Prediction(self.tag, probs, self.threshold, self.types)]
コード例 #6
0
    def parse(self, output):
        probs = list()
        for residue in output.decode('utf-8').split("\n"):
            if len(residue) == 0:
                continue
            if residue[0] in ["O", "D"]:
                probs.append(round(float(residue.split()[1]), 4))

        if probs:
            return [Prediction(self.tag, probs, self.threshold, self.types)]
コード例 #7
0
 def parse(self, output):
     probs = list()
     for line in output.decode('utf-8').split("\n"):
         if len(line) > 0 and line[0] != '>':
             for pred in line:
                 if pred == 'X':
                     probs.append(1.0)
                 else:
                     probs.append(0.0)
     if probs:
         return [Prediction(self.tag, probs, self.threshold, self.types)]
コード例 #8
0
    def parse(self, output):
        probs = {
            ele['pred']: ele['p']
            for ele in json.loads(
                output.decode('utf-8').rstrip("\n").replace("\'", "\""))
        }

        preds = list()
        for subtag in self.tag:
            if probs[subtag]:
                preds.append(
                    Prediction(subtag, probs[subtag], self.thresholds[subtag],
                               self.types))

        return preds
コード例 #9
0
    def parse(self, output):
        probs = {t: list() for t in self.tag}

        for output_line in output.decode('utf-8').split("\n"):
            if not output_line.startswith("#"):
                output_line = output_line.split()

                if len(output_line) > 0:
                    # LINE: aminoacid, secstruct, helix_score, sheet_score, coil_score
                    for subtag, score in zip(self.tag, output_line[2:]):
                        probs[subtag].append(float(score))

        preds = list()
        for subtag in self.tag:
            if probs[subtag]:
                preds.append(
                    Prediction(subtag, probs[subtag], self.thresholds[subtag],
                               self.types))

        return preds
コード例 #10
0
    def parse(self, output):
        """Parse VSL2b output and extract probabilities

        :param output: VSL2b output
        :types output: str
        :return: ID prediction probabilities::

            [0.9994, 0.9994, 0.9995, 0.9995, ...]

        :rtype: list
        """
        processlines = False
        probs = list()
        for row in output.decode('utf-8').split("\n"):
            if row == "----------------------------------------":
                processlines = True
            elif row == "========================================":
                processlines = False
            elif processlines and "-" not in row:
                probs.append(round(float(row.split()[2].replace(',', '.')), 4))

        if probs:  # may not get results if sequence has non-standard residues (X,etc)outfile
            return [Prediction(self.tag, probs, self.threshold, self.types)]
コード例 #11
0
    def parse(self, output):
        probs = json.loads(output.decode('utf-8').replace("\'", "\""))[0]['p']

        if probs:
            return [Prediction(self.tag, probs, self.threshold, self.types)]