get the value at species level
553998
def _summarize_kraken(fn):
    """"""
    kraken = {}
    list_sp, list_value = [], []
    with open(fn) as handle:
        for line in handle:
            cols = line.strip().split("\t")
            sp = cols[5].strip()
            if len(sp.split(" ")) > 1 and not sp.startswith("cellular"):
                list_sp.append(sp)
                list_value.append(cols[0])
    kraken = {"kraken_sp": list_sp, "kraken_value": list_value}
    return kraken
453925
def setSpeciesFromJson(self, speciesJson):
        
        try:
            parsed = protocol.fromJson(speciesJson, protocol.OntologyTerm)
        except:
            raise exceptions.InvalidJsonException(speciesJson)
        self._species = protocol.toJsonDict(parsed)
884541
def get_value(self) -> ScalarType:
        
        if self.yaml_node.tag == 'tag:yaml.org,2002:str':
            return self.yaml_node.value
        if self.yaml_node.tag == 'tag:yaml.org,2002:int':
            return int(self.yaml_node.value)
        if self.yaml_node.tag == 'tag:yaml.org,2002:float':
            return float(self.yaml_node.value)
        if self.yaml_node.tag == 'tag:yaml.org,2002:bool':
            return self.yaml_node.value in ['TRUE', 'True', 'true']
        if self.yaml_node.tag == 'tag:yaml.org,2002:null':
            return None
        raise RuntimeError('This node with tag {} is not of the right type'
                           ' for get_value()'.format(self.yaml_node.tag))
839432
def get_val(self, x):
        """"""
        try:
            if self.subtype == 'integer':
                return int(round(x[self.col_name]))
            else:
                if np.isnan(x[self.col_name]):
                    return self.default_val

                return x[self.col_name]

        except (ValueError, TypeError):
            return self.default_val
725333
def _get_value(self, node, scope, ctxt, stream):
        

        res = self._handle_node(node, scope, ctxt, stream)

        if isinstance(res, fields.Field):
            return res._pfp__value

        # assume it's a constant
        else:
            return res
883197
def stringClade(taxrefs, name, at):
    ''''''
    string = []
    for ref in taxrefs:
        # distance is the difference between the taxonomic level of the ref
        #  and the current level of the tree growth
        d = float(at-ref.level)
        # ensure no spaces in ident, Newick tree cannot have spaces
        ident = re.sub("\s", "_", ref.ident)
        string.append('{0}:{1}'.format(ident, d))
    # join into single string with a name for the clade
    string = ','.join(string)
    string = '({0}){1}'.format(string, name)
    return string
452041
def normalize_init_values(cls, release, species, server):
        
        release = check_release_number(release)
        species = check_species_object(species)
        return (release, species, server)
1051162
def _extract_number_of_taxa(self):
        
        n_taxa = dict()
        for i in self.seq_records:
            if i.gene_code not in n_taxa:
                n_taxa[i.gene_code] = 0
            n_taxa[i.gene_code] += 1
        number_taxa = sorted([i for i in n_taxa.values()], reverse=True)[0]
        self.number_taxa = str(number_taxa)
942487
private String getPropertyValue(String level, String name)
    {
        return getDefForLevel(level).getProperty(name);
    }
731196
function checkLevel (type) {
  const logLevel = (global.JUDEnvironment && global.JUDEnvironment.logLevel) || 'log'
  return levelMap[logLevel] && levelMap[logLevel][type]
}
1135171
def get_multiplicon_segments(self, value):
        
        sql = '''SELECT genome, first, last FROM segments
                   WHERE multiplicon=:mp'''
        cur = self._dbconn.cursor()
        cur.execute(sql, {'mp': str(value)})
        result = cur.fetchall()
        cur.close()
        segdict = collections.defaultdict(tuple)
        for genome, start, end in result:
            segdict[genome] = (start, end)
        return segdict
1209067
function getLevel(levelConfig) {
  const level = loadLevel(levelConfig);
  return JSON.parse(JSON.stringify(level));
}
536562
def summarize_taxa(biom):
    
    tamtcounts = defaultdict(int)
    tot_seqs = 0.0

    for row, col, amt in biom['data']:
        tot_seqs += amt
        rtax = biom['rows'][row]['metadata']['taxonomy']
        for i, t in enumerate(rtax):
            t = t.strip()
            if i == len(rtax)-1 and len(t) > 3 and len(rtax[-1]) > 3:
                t = 's__'+rtax[i-1].strip().split('_')[-1]+'_'+t.split('_')[-1]
            tamtcounts[t] += amt

    lvlData = {lvl: levelData(tamtcounts, tot_seqs, lvl) for lvl in ['k', 'p', 'c', 'o', 'f', 'g', 's']}

    return tot_seqs, lvlData
600127
def adjust_clade(rec, rank, clade)
      if %i[species subspecies].include? rank
        clade = [rec[:genus], rec[:species]]
        clade << rec[:subspecies] if rank == :subspecies
        clade.join(" ").gsub(/[\s]+/, " ").strip
      else
        clade
      end
    end
329600
def get_children(engine, parent_ids, rank='species', schema=None):
    

    if not parent_ids:
        return []

    nodes = schema + '.nodes' if schema else 'nodes'
    names = schema + '.names' if schema else 'names'

    cmd = ('select tax_id, tax_name, rank '
           'from {} join {} using (tax_id) '
           'where parent_id = :tax_id and is_primary').format(nodes, names)

    species = []
    for parent_id in parent_ids:
        result = engine.execute(sqlalchemy.sql.text(cmd), tax_id=parent_id)
        keys = list(result.keys())
        rows = [dict(list(zip(keys, row))) for row in result.fetchall()]
        for r in rows:
            if r['rank'] == rank and 'sp.' not in r['tax_name']:
                species.append(r)
        others = [r for r in rows if r['rank'] not in (rank, 'no_rank')]
        if others:
            _, s = get_children(engine, [r['tax_id'] for r in others])
            species.extend(s)

    return keys, species
328839
@SuppressWarnings("unchecked")
  public E getLevel()
  {
    Thread thread = Thread.currentThread();
    ClassLoader loader = thread.getContextClassLoader();

    for (; loader != null; loader = loader.getParent()) {
      if (loader instanceof EnvironmentClassLoader) {
        EnvironmentClassLoader envLoader = (EnvironmentClassLoader) loader;

        return (E) envLoader.getAttribute(_varName);
      }
    }

    return _globalValue;
  }
107456
def check_species_object(species_name_or_object):
    
    if isinstance(species_name_or_object, Species):
        return species_name_or_object
    elif isinstance(species_name_or_object, str):
        return find_species_by_name(species_name_or_object)
    else:
        raise ValueError("Unexpected type for species: %s : %s" % (
            species_name_or_object, type(species_name_or_object)))