def query_gene(self, gene, color=None, invert=False):
        qi = self.columns[0].index(gene)
        ndata = len(self.data)
        for col in self.columns[1:]:
            upstream_dist = downstream_dist = 1000
            # search upstream
            for i in xrange(qi - 1, -1, -1):
                if col[i] not in (".", ""):
                    upstream = col[i]
                    upstream_dist = qi - i
                    break
            # search downstream
            for i in xrange(qi, ndata):
                if col[i] not in (".", ""):
                    downstream = col[i]
                    downstream_dist = i - qi
                    break
            closest = upstream if upstream_dist < downstream_dist \
                    else downstream
            # output in .simple format
            if invert:
                line = "\t".join(str(x) for x in \
                        (closest, closest, gene, gene, 0, "+"))
            else:
                line = "\t".join(str(x) for x in \
                        (gene, gene, closest, closest, 0, "+"))
            if color is not None:
                line = color + "*" + line
            yield line
Used in mcscanq() for query
dataset/ETHPy150Open tanghaibao/jcvi/compara/synteny.py/BlockFile.query_gene