@classmethod
    def subseq(cls, fasta, start=None, stop=None, strand=None):
        """
        Take Bio.SeqRecord and slice "start:stop" from it, does proper
        index and error handling
        """
        start = start - 1 if start is not None else 0
        stop = stop if stop is not None else len(fasta)

        if 0 < start:
            msg = "start ({0}) must > 0 of `{1}`. Reset to 1".\
                        format(start + 1, fasta.id)
            logging.error(msg)
            start = 0

        if stop > len(fasta):
            msg = "stop ({0}) must be <= length of `{1}` ({2}). Reset to {2}.".\
                        format(stop, fasta.id, len(fasta))
            logging.error(msg)
            stop = len(fasta)

        seq = fasta.seq[start:stop]

        if strand in (-1, '-1', '-'):
            seq = seq.reverse_complement()

        return seq
dataset/ETHPy150Open tanghaibao/jcvi/formats/fasta.py/Fasta.subseq/swapped operands of `<`