Basic marker details loading.

            (chr, rsid, gen. dist, pos, allelel 1, allele2)

        :param map3: When true, ignore the genetic distance column
        :return: None
167636
def load_bim(self, map3=False):
        
        cols = [0, 1, 3, 4, 5]
        if map3:
            cols = [0, 1, 2, 3, 4]
        logging.info("Loading file: %s" % self.bim_file)
        val = sys_call('wc -l %s' % (self.bim_file))[0][0].split()[0]
        marker_count = int(val)
        self.markers = numpy.zeros((marker_count, 2), dtype=int)
        self.rsids = []
        self.alleles = []

        with open(self.bim_file) as file:
            index = 0
            for line in file:
                if map3:
                    chr, rsid, pos, al1, al2 = line.strip().split()
                else:
                    chr, rsid, gd, pos, al1, al2 = line.strip().split()
                self.markers[index, 0] = int(chr)
                self.markers[index, 1] = int(pos)
                self.alleles.append([al1, al2])
                self.rsids.append(rsid)
                index += 1
        self.locus_count = self.markers.shape[0]
417309
def marker_(self, lat, long, text, pmap, color=None, icon=None):
        
        try:
            xmap = self._marker(lat, long, text, pmap, color, icon)
            return xmap
        except Exception as e:
            self.err(e, self.marker_, "Can not get marker")
452176
def chk_genes(self, study, pop, assoc=None):
        """"""
        if len(pop) < len(study):
            exit("\nERROR: The study file contains more elements than the population file. "
                 "Please check that the study file is a subset of the population file.\n")
        # check the fraction of genomic ids that overlap between study and population
        overlap = self.get_overlap(study, pop)
        if overlap < 0.95:
            sys.stderr.write("\nWARNING: only {} fraction of genes/proteins in study are found in "
                             "the population  background.\n\n".format(overlap))
        if overlap <= self.args.min_overlap:
            exit("\nERROR: only {} of genes/proteins in the study are found in the "
                 "background population. Please check.\n".format(overlap))
        # Population and associations
        if assoc is not None and pop.isdisjoint(assoc.keys()):
            if self.objanno.name == 'gene2go':
                err = ('**FATAL: NO POPULATION ITEMS SEEN IN THE NCBI gene2go ANNOTATIONS '
                       'FOR taxid({T}). TRY: --taxid=<taxid number>')
                exit(err.format(T=next(iter(self.objanno.taxid2asscs.keys()))))
            else:
                exit('**FATAL: NO POPULATION ITEMS SEEN IN THE ANNOTATIONS')
958377
public void info( Marker marker, String msg )
    {
        if( m_delegate.isInfoEnabled() )
        {
            setMDCMarker( marker );
            m_delegate.inform( msg, null );
            resetMDCMarker();
        }
    }
975020
def write_map(self, path):
        '''

        '''
        starts = [index[0] for index in self.overlap_indices]
        features = []
        for i, start in enumerate(starts):
            stop = start + len(self.overlaps[i])
            name = 'overlap {}'.format(i + 1)
            feature_type = 'misc'
            strand = 0
            features.append(coral.Feature(name, start, stop, feature_type,
                                          strand=strand))
        seq_map = coral.DNA(self.template, features=features)
        coral.seqio.write_dna(seq_map, path)
1302738
def _mpl_marker2pgfp_marker(data, mpl_marker, marker_face_color):
    
    # try default list
    try:
        pgfplots_marker = _MP_MARKER2PGF_MARKER[mpl_marker]
    except KeyError:
        pass
    else:
        if (marker_face_color is not None) and pgfplots_marker == "o":
            pgfplots_marker = "*"
            data["tikz libs"].add("plotmarks")
        marker_options = None
        return (data, pgfplots_marker, marker_options)

    # try plotmarks list
    try:
        data["tikz libs"].add("plotmarks")
        pgfplots_marker, marker_options = _MP_MARKER2PLOTMARKS[mpl_marker]
    except KeyError:
        # There's no equivalent for the pixel marker (,) in Pgfplots.
        pass
    else:
        if (
            marker_face_color is not None
            and (
                not isinstance(marker_face_color, str)
                or marker_face_color.lower() != "none"
            )
            and pgfplots_marker not in ["|", "-", "asterisk", "star"]
        ):
            pgfplots_marker += "*"
        return (data, pgfplots_marker, marker_options)

    return data, None, None
1344741
def run_haplotyper(align_bams, items, ref_file, assoc_files,
                     region=None, out_file=None):
    
    if out_file is None:
        out_file = "%s-variants.vcf.gz" % utils.splitext_plus(align_bams[0])[0]
    if not utils.file_exists(out_file):
        variant_regions = bedutils.population_variant_regions(items, merged=True)
        interval = _get_interval(variant_regions, region, out_file, items)
        with file_transaction(items[0], out_file) as tx_out_file:
            dbsnp = "--dbsnp %s" % (assoc_files.get("dbsnp")) if "dbsnp" in assoc_files else ""
            bams = " ".join(["-i %s" % x for x in align_bams])
            license = license_export(items[0])
            cores = dd.get_num_cores(items[0])
            out_mode = "--emit_mode gvcf" if joint.want_gvcf(items) else ""
            cmd = ("{license}sentieon driver -t {cores} -r {ref_file} "
                   "{bams} {interval} --algo Haplotyper {out_mode} {dbsnp} {tx_out_file}")
            do.run(cmd.format(**locals()), "Sentieon Haplotyper")
    return out_file
40390
public void moveMapInfo(Map<String,Object> mapReplyHeader, Map<String,Object> mapInHeader, String strReplyParam, String strInParam)
    {
        if (mapInHeader != null)
            if (mapInHeader.get(strInParam) != null)
                if (mapReplyHeader != null)
                    mapReplyHeader.put(strReplyParam, mapInHeader.get(strInParam));
    }
1236265
def interpret(marker, execution_context=None):
    
    try:
        expr, rest = parse_marker(marker)
    except Exception as e:
        raise SyntaxError('Unable to interpret marker syntax: %s: %s' % (marker, e))
    if rest and rest[0] != '#':
        raise SyntaxError('unexpected trailing data in marker: %s: %s' % (marker, rest))
    context = dict(DEFAULT_CONTEXT)
    if execution_context:
        context.update(execution_context)
    return evaluator.evaluate(expr, context)
419616
def genemark(args):
    
    p = OptionParser(genemark.__doc__)
    p.add_option("--junctions", help="Path to `junctions.bed` from Tophat2")
    p.set_home("gmes")
    p.set_cpus(cpus=32)
    opts, args = p.parse_args(args)

    if len(args) != 2:
        sys.exit(not p.print_help())

    species, fastafile = args
    junctions = opts.junctions
    mhome = opts.gmes_home

    license = op.expanduser("~/.gm_key")
    assert op.exists(license), "License key ({0}) not found!".format(license)
    cmd = "{0}/gmes_petap.pl --sequence {1}".format(mhome, fastafile)
    cmd += " --cores {0}".format(opts.cpus)
    if junctions:
        intronsgff = "introns.gff"
        if need_update(junctions, intronsgff):
            jcmd = "{0}/bet_to_gff.pl".format(mhome)
            jcmd += " --bed {0} --gff {1} --label Tophat2".\
                    format(junctions, intronsgff)
            sh(jcmd)
        cmd += " --ET {0} --et_score 10".format(intronsgff)
    else:
        cmd += " --ES"
    sh(cmd)

    logging.debug("GENEMARK matrix written to `output/gmhmm.mod")
447446
def _fix_genotypes_object(self, genotypes, variant_info):
        """"""
        # Checking the name (if there were duplications)
        if self.has_index and variant_info.name != genotypes.variant.name:
            if not variant_info.name.startswith(genotypes.variant.name):
                raise ValueError("Index file not synced with IMPUTE2 file")
            genotypes.variant.name = variant_info.name

        # Trying to set multi-allelic information
        if self.has_index and self._index_has_location:
            # Location was in the index, so we can automatically set the
            # multi-allelic state of the genotypes
            genotypes.multiallelic = variant_info.multiallelic

        else:
            # Location was not in the index, so we check one marker before and
            # after the one we found
            logging.warning("Multiallelic variants are not detected on "
                            "unindexed files.")
1044526
def load(self,cache_genotype=False,cache_phenotype=True):
        
        self.f = h5py.File(self.file_name,'r')
        self.pheno = self.f['phenotype']
        self.geno  = self.f['genotype']
        #TODO: load all row and column headers for genotype and phenotype

        #parse out thse we alwasy need for convenience
        self.genoM = self.geno['matrix']

        self.phenoM = self.pheno['matrix']
        self.sample_ID = self.geno['row_header']['sample_ID'][:]
        self.genoChrom = self.geno['col_header']['chrom'][:]
        self.genoPos   = self.geno['col_header']['pos'][:]
        if 'pos_cum' in list(self.geno['col_header'].keys()):
            self.genoPos_cum   = self.geno['col_header']['pos_cum'][:]
        else:
            self.genoPos_cum = None
        self.phenotype_ID = self.pheno['col_header']['phenotype_ID'][:]


        #cache?
        if cache_genotype:
            self.genoM = self.genoM[:]
        if cache_phenotype:
            self.phenoM = self.phenoM[:]
    
        # Additional pheno col header
        headers = list(self.pheno['col_header'].keys())
        if 'gene_ID' in headers:
            self.eqtl = True
            self.geneID = self.pheno['col_header']['gene_ID'][:]
            self.gene_pos = SP.array([self.pheno['col_header']['gene_chrom'][:],self.pheno['col_header']['gene_start'][:],self.pheno['col_header']['gene_end']],dtype='int').T
            self.geneIDs= list(set(self.geneID))
        else:
            self.eqtl = False
        if 'environment' in headers:
            self.E  = self.pheno['col_header/environment'][:]
            self.Es = list(set(self.E))
        else:
            self.E = None

        #dimensions
        self.N = self.genoM.shape[0]
        self.S = self.genoM.shape[1]
        self.P = self.phenoM.shape[1]
        assert (self.genoM.shape[0]==self.phenoM.shape[0]), 'dimension missmatch'
871519
def _compile_marker(self, schema):
        
        # Prepare self
        self.compiled_type = const.COMPILED_TYPE.MARKER

        # If this marker is not instantiated -- do it with an identity callable which is valid for everything
        if issubclass(type(schema), six.class_types):
            schema = schema(Identity)  \
                .on_compiled(name=Identity.name)  # Set a special name on it

        # Compile Marker's schema
        key_schema = self.sub_compile(schema.key, matcher=self.matcher)
        schema.on_compiled(key_schema=key_schema, name=key_schema.name)

        # Marker is a callable
        self.name = schema.name
        return schema
1124645
def tmarker(self, lat, long, text, color=None, icon=None, style=None):
        
        try:
            self.dsmap = self._marker(
                lat, long, text, self.dsmap, color, icon, True, style)
            return self.dsmap
        except Exception as e:
            self.err(e, self.tmarker, "Can not get text marker")
1265275
def cli(ctx, feature_id, organism="", sequence=""):
    
    return ctx.gi.annotations.get_gff3(feature_id, organism=organism, sequence=sequence)
941290
def rename(args):
    
    p = OptionParser(rename.__doc__)
    p.set_outfile()
    opts, args = p.parse_args(args)

    if len(args) != 2:
        sys.exit(not p.print_help())

    mstmap, bedfile = args
    markersbed = Bed(bedfile)
    markers = markersbed.order

    data = MSTMap(mstmap)
    header = data.header
    header = [header[0]] + ["seqid", "start"] + header[1:]
    renamed = []
    for b in data:
        m, geno = b.id, b.genotype
        om = m
        if m not in markers:
            m = m.rsplit(".", 1)[0]
            if m not in markers:
                continue

        i, mb = markers[m]
        renamed.append([om, mb.seqid, mb.start, "\t".join(list(geno))])

    renamed.sort(key=lambda x: (x[1], x[2]))
    fw = must_open(opts.outfile, "w")
    print("\t".join(header), file=fw)
    for d in renamed:
        print("\t".join(str(x) for x in d), file=fw)
1163375
def make_vslc_label(self, gene_label, allele1_label, allele2_label):
        

        vslc_label = ''

        if gene_label is None and allele1_label is None and allele2_label is None:
            LOG.error("Not enough info to make vslc label")
            return None

        top = self.make_variant_locus_label(gene_label, allele1_label)
        bottom = ''
        if allele2_label is not None:
            bottom = self.make_variant_locus_label(gene_label, allele2_label)

        vslc_label = '/'.join((top, bottom))

        return vslc_label