Code Duplication    Length = 16-17 lines in 2 locations

goatools/cli/gos_get.py 1 location

@@ 68-84 (lines=17) @@
65
                prt.write("  {N} GO IDs READ: {TXT}\n".format(N=len(goids), TXT=go_file))
66
        return goids
67
68
    @staticmethod
69
    def get_goargs(go_args, prt):
70
        """Get GO IDs and colors for GO IDs from the GO ID runtime arguments."""
71
        goids = set()
72
        go2color = {}
73
        # Match on "GO ID" or "GO ID and color"
74
        re_gocolor = re.compile(r'(GO:\d{7})((?:#[0-9a-fA-F]{6})?)')
75
        for go_arg in go_args:
76
            mtch = re_gocolor.match(go_arg)
77
            if mtch:
78
                goid, color = mtch.groups()
79
                goids.add(goid)
80
                if color:
81
                    go2color[goid] = color
82
            elif prt:
83
                prt.write("WARNING: UNRECOGNIZED ARG({})".format(go_arg))
84
        return goids
85
86
# Copyright (C) 2016-2018, DV Klopfenstein, H Tang. All rights reserved.
87

goatools/cli/gosubdag_plot.py 1 location

@@ 122-137 (lines=16) @@
119
        return [ret['GOs'], ret['go2color']]
120
121
    def _goargs(self, ret, go_args):
122
        """Get GO IDs and colors for GO IDs from the GO ID runtime arguments."""
123
        goids = set()
124
        go2color = {}
125
        # Match on "GO ID" or "GO ID and color"
126
        re_gocolor = re.compile(r'(GO:\d{7})((?:#[0-9a-fA-F]{6})?)')
127
        for go_arg in go_args:
128
            mtch = re_gocolor.match(go_arg)
129
            if mtch:
130
                goid, color = mtch.groups()
131
                goids.add(goid)
132
                if color:
133
                    go2color[goid] = color
134
            else:
135
                print("WARNING: UNRECOGNIZED ARG({})".format(go_arg))
136
        self._update_ret(ret, goids, go2color)
137
138
    def _rdtxt_gos(self, ret, go_file):
139
        """Read GO IDs from a file."""
140
        if not os.path.exists(go_file):