예제 #1
0
파일: edit.py 프로젝트: zlangley/hgvs
    def format(self, conf=None):
        p_3_letter, p_term_asterisk = self._format_config_aa(conf)

        st_length = self.length or ""
        if p_3_letter:
            if p_term_asterisk:
                s = "{alt}fs*{length}".format(alt=aa1_to_aa3(self.alt), length=st_length)
            else:
                s = "{alt}fsTer{length}".format(alt=aa1_to_aa3(self.alt), length=st_length)
        else:
            s = "{alt}fs*{length}".format(alt=self.alt, length=st_length)
        return "(" + s + ")" if self.uncertain else s
예제 #2
0
파일: edit.py 프로젝트: biocommons/hgvs
    def format(self, conf=None):
        if self.ref is None and self.alt is None:
            # raise HGVSError("RefAlt: ref and alt sequences are both undefined")
            return "="

        p_3_letter, p_term_asterisk, p_init_met = self._format_config_aa(conf)

        if self.init_met and p_init_met:
            s = "Met1?"
        elif self.init_met and not p_init_met:
            s = "?"
        # subst and delins
        elif self.ref is not None and self.alt is not None:
            if self.ref == self.alt:
                if p_3_letter:
                    s = "{ref}=".format(ref=aa1_to_aa3(self.ref))
                    if p_term_asterisk and s == "Ter=":
                        s = "*="
                else:
                    s = "{ref}=".format(ref=self.ref)
            elif len(self.ref) == 1 and len(self.alt) == 1:
                if p_3_letter:
                    s = aa1_to_aa3(self.alt)
                    if p_term_asterisk and s == "Ter":
                        s = "*"
                else:
                    s = self.alt
            else:
                if p_3_letter:
                    s = "delins{alt}".format(alt=aa1_to_aa3(self.alt))
                    if p_term_asterisk and s == "delinsTer":
                        s = "delins*"
                else:
                    s = "delins{alt}".format(alt=self.alt)

        # del case
        elif self.ref is not None and self.alt is None:
            s = "del"

        # ins case
        elif self.ref is None and self.alt is not None:
            if p_3_letter:
                s = "ins{alt}".format(alt=aa1_to_aa3(self.alt))
                if p_term_asterisk and s == "insTer":
                    s = "ins*"
            else:
                s = "ins{alt}".format(alt=self.alt)

        else:
            raise RuntimeError("Should not be here")

        return "(" + s + ")" if self.uncertain else s
예제 #3
0
파일: edit.py 프로젝트: zlangley/hgvs
    def format(self, conf=None):
        p_3_letter, p_term_asterisk = self._format_config_aa(conf)

        st_alt = self.alt or ""
        st_aaterm = self.aaterm or ""
        st_length = self.length or ""
        if p_3_letter:
            st_alt = aa1_to_aa3(st_alt)
            st_aaterm = aa1_to_aa3(st_aaterm)
            if p_term_asterisk and st_alt == "Ter":
                st_alt = "*"
            if p_term_asterisk and st_aaterm == "Ter":
                st_aaterm = "*"

        s = "{alt}ext{term}{length}".format(alt=st_alt, term=st_aaterm, length=st_length)
        return "(" + s + ")" if self.uncertain else s
예제 #4
0
    def format(self, conf=None):
        p_3_letter, p_term_asterisk = self._format_config(conf)

        if p_3_letter:
            s = aa1_to_aa3(self.alt) if self.alt != "?" else self.alt
            if p_term_asterisk and s == "Ter":
                s = "*"
        else:
            s = self.alt
        return "(" + s + ")" if self.uncertain else s
예제 #5
0
파일: location.py 프로젝트: SunbyMoon/hgvs
    def format(self, conf=None):
        self.validate()

        p_3_letter = hgvs.global_config.formatting.p_3_letter
        p_term_asterisk = hgvs.global_config.formatting.p_term_asterisk
        if conf and "p_3_letter" in conf and conf["p_3_letter"] is not None:
            p_3_letter = conf["p_3_letter"]
        if conf and "p_term_asterisk" in conf and conf["p_term_asterisk"] is not None:
            p_term_asterisk = conf["p_term_asterisk"]

        pos = "?" if self.base is None else str(self.base)
        if p_3_letter:
            aa = "?" if self.aa is None else aa1_to_aa3(self.aa)
            if p_term_asterisk and aa == "Ter":
                aa = "*"
        else:
            aa = "?" if self.aa is None else self.aa
        s = aa + pos
        return "(" + s + ")" if self.uncertain else s
예제 #6
0
파일: location.py 프로젝트: jmuhlich/hgvs
 def __str__(self):
     self.validate()
     pos = '?' if self.base is None else str(self.base)
     aa = '?' if self.aa is None else aa1_to_aa3(self.aa)
     s = aa + pos
     return '('+s+')' if self.uncertain else s