def __rshift__(self, index):
        """Rotate the sequence clockwise, preserving annotations.
        """
        index %= len(self.seq)  # avoid unnecessary cycles

        if index == 0:
            return self
        elif index < 0:
            return self << -index

        newseq = self.seq[-index:] + self.seq[:-index]
        newfeats = []
        newletan = {
            k: v[index:] + v[:index] for k, v in six.iteritems(self.letter_annotations)
        }

        for feature in self.features:
            loc = feature.location
            if loc is None:
                newloc = None
            elif feature.type == "source" and loc.start == 0 and loc.end == len(self):
                newloc = loc
            else:
                _newloc = []
                for part in (loc + index).parts:
                    if part.end >= len(newseq) and part.start >= len(newseq):
                        r = part.start // len(newseq)  # remainder is used to
                        _newloc.append(
                            FeatureLocation(  # make sure that part.end
                                start=part.start
                                - r * len(newseq),  # is always after part.start
                                end=part.end
                                - r * len(newseq),  # even on additional end
                                strand=part.strand,  # overlap
                                ref=part.ref,
                                ref_db=part.ref_db,
                            )
                        )
                    else:
                        _newloc.append(part)
                newloc = _newloc[0] if len(_newloc) == 1 else CompoundLocation(_newloc)
            newfeats.append(
                SeqFeature(
                    location=newloc,
                    type=feature.type,
                    id=feature.id,
                    qualifiers=feature.qualifiers,
                )
            )

        return type(self)(
            seq=newseq,
            id=self.id,
            name=self.name,
            description=self.description,
            dbxrefs=self.dbxrefs,
            features=newfeats,
            annotations=self.annotations,
            letter_annotations=newletan,
        )
def __rshift__ ( self , index ) : index %= len ( self . seq ) if index == 0 : return self elif index < 0 : return self << - index newseq = self . seq [ - index : ] + self . seq [ : - index ] newfeats = [ ] newletan = { k : v [ index : ] + v [ : index ] for k , v in six . iteritems ( self . letter_annotations ) } for feature in self . features : loc = feature . location if loc is None : newloc = None elif feature . type == "source" and loc . start == 0 and loc . end == len ( self ) : newloc = loc else : _newloc = [ ] for part in ( loc + index ) . parts : if part . end >= len ( newseq ) and part . start >= len ( newseq ) : r = part . start // len ( newseq ) _newloc . append ( FeatureLocation ( start = part . start - r * len ( newseq ) , end = part . end - r * len ( newseq ) , strand = part . strand , ref = part . ref , ref_db = part . ref_db , ) ) else : _newloc . append ( part ) newloc = _newloc [ 0 ] if len ( _newloc ) == 1 else CompoundLocation ( _newloc ) newfeats . append ( SeqFeature ( location = newloc , type = feature . type , id = feature . id , qualifiers = feature . qualifiers , ) ) return type ( self ) ( seq = newseq , id = self . id , name = self . name , description = self . description , dbxrefs = self . dbxrefs , features = newfeats , annotations = self . annotations , letter_annotations = newletan , )
Rotate the sequence clockwise, preserving annotations.