示例#1
0
            answer.dbxrefs = self.dbxrefs[:]
        if isinstance(features, list):
            answer.features = features
        elif features:
            # Copy the old features, adjusting location and string
            l = len(answer)
            answer.features = [f._flip(l) for f in self.features]
            # The old list should have been sorted by start location,
            # reversing it will leave it sorted by what is now the end position,
            # so we need to resort in case of overlapping features.
            # NOTE - In the common case of gene before CDS (and similar) with
            # the exact same locations, this will still maintain gene before CDS
            answer.features.sort(key=lambda x: x.location.start.position)
        if isinstance(annotations, dict):
            answer.annotations = annotations
        elif annotations:
            # Copy the old annotations,
            answer.annotations = self.annotations.copy()
        if isinstance(letter_annotations, dict):
            answer.letter_annotations = letter_annotations
        elif letter_annotations:
            # Copy the old per letter annotations, reversing them
            for key, value in self.letter_annotations.items():
                answer._per_letter_annotations[key] = value[::-1]
        return answer


if __name__ == "__main__":
    from anarci.Bio._utils import run_doctest
    run_doctest()
示例#2
0
        else:
            id = self.clean(record.id)
            description = self.clean(record.description)
            if description and description.split(None, 1)[0] == id:
                # The description includes the id at the start
                title = description
            elif description:
                title = "%s %s" % (id, description)
            else:
                title = id

        assert "\n" not in title
        assert "\r" not in title
        self.handle.write(">%s\n" % title)

        data = self._get_seq_string(record)  # Catches sequence being None

        assert "\n" not in data
        assert "\r" not in data

        if self.wrap:
            for i in range(0, len(data), self.wrap):
                self.handle.write(data[i:i + self.wrap] + "\n")
        else:
            self.handle.write(data + "\n")


if __name__ == "__main__":
    from anarci.Bio._utils import run_doctest
    run_doctest(verbose=0)