Exemplo n.º 1
0
    def __init__(self, inarg, Stype=FS.SIMILARITY, new=True):

        self.thisown = 0
        # First check if we are passing the SWIG wrapped type.
        if isinstance(inarg, FS_Smatrix):
            if new:
                self.this = FS.Smatrix_copy(inarg)
                self.thisown = 1
            else:
                self.this = inarg
                self.thisown = 1
        elif isinstance(inarg, str):
            # Load from file
            self.this = FS.Smatrix_load(inarg)
            self.thisown = 1
            # Dictionary - Biopython matrix
        elif isinstance(inarg, dict):
            self.this = FS.new_Smatrix(inarg, Stype)
            self.thisown = 1
            # Instance of ScoreMatrix
        elif isinstance(inarg, ScoreMatrix):
            self.this = FS.Smatrix_copy(inarg.this)
            self.thisown = 1
        else:
            raise TypeError, "Constructor only accepts"\
                  " a filename, a dictionary"\
                  " and an instance of ScoreMatrix."

        self.alphabet = FS.Smatrix_alphabet_get(self)
        self.mean = self._calc_mean()