Retrieve all samples for a given study (from its study ID).

@param studyId   Study ID
@return          Sample list
431369
public List<Sample> getSamples(String studyId) {
        VariantStudyMetadata variantStudyMetadata = getVariantStudyMetadata(studyId);
        if (variantStudyMetadata == null) {
            logger.error("Study not found. Check your study ID: '{}'", studyId);
            return null;
        }

        List<Sample> samples = new ArrayList<>();
        if (variantStudyMetadata.getIndividuals() != null) {
            for (org.opencb.biodata.models.metadata.Individual individual : variantStudyMetadata.getIndividuals()) {
                for (Sample sample : individual.getSamples()) {
                    if (sample.getAnnotations() == null) {
                        sample.setAnnotations(new HashMap<>());
                    }
                    samples.add(sample);
                }
            }
        }
        return samples;
    }
443403
def _get_study_txt(self, goid):
        """"""
        if self.go2res is not None:
            res = self.go2res.get(goid, None)
            if res is not None:
                if self.study_items is not None:
                    return self._get_item_str(res)
                else:
                    return self.pltvars.fmtres.format(
                        study_count=res.study_count)
946889
public List<GitlabProject> getGroupProjects(Integer groupId) {
        String tailUrl = GitlabGroup.URL + "/" + groupId + GitlabProject.URL + PARAM_MAX_ITEMS_PER_PAGE;
        return retrieve().getAll(tailUrl, GitlabProject[].class);
    }
229111
public void removeIndividual(String individualId, String studyId) {
        // Sanity check
        if (StringUtils.isEmpty(individualId)) {
            logger.error("Individual ID {} is null or empty.", individualId);
            return;
        }

        VariantStudyMetadata variantStudyMetadata = getVariantStudyMetadata(studyId);
        if (variantStudyMetadata == null) {
            logger.error("Study not found. Check your study ID: '{}'", studyId);
            return;
        }
        if (variantStudyMetadata.getIndividuals() != null) {
            for (int i = 0; i < variantStudyMetadata.getIndividuals().size(); i++) {
                if (individualId.equals(variantStudyMetadata.getIndividuals().get(i).getId())) {
                    variantStudyMetadata.getIndividuals().remove(i);
                    return;
                }
            }
        }
    }
776576
public Set<String> getIdsForIdsWithAncestors(Collection<String> termIds) {
        Stack<String> idsToConsider = new Stack<String>();
        idsToConsider.addAll(termIds);
        Set<String> resultIds = new HashSet<String>();
        while (!idsToConsider.isEmpty()) {
            String id = idsToConsider.pop();
            if (!resultIds.contains(id)) {
                resultIds.add(id);
                if (terms.containsKey(id))
                    idsToConsider.addAll(terms.get(id).getIsA());
            }
        }
        return resultIds;
    }
621156
public List<Pedigree> getPedigree(String studyId) {
        Member dest;
        Map<String, Pedigree> pedigreeMap = new HashMap<>();
        Map<String, Member> individualMap = new HashMap<>();

        VariantStudyMetadata variantStudyMetadata = getVariantStudyMetadata(studyId);
        if (variantStudyMetadata != null) {

            // first loop
            for (org.opencb.biodata.models.metadata.Individual src: variantStudyMetadata.getIndividuals()) {

                String pedigreeName = src.getFamily();
                if (!pedigreeMap.containsKey(pedigreeName)) {
                    pedigreeMap.put(pedigreeName, new Pedigree(pedigreeName, new ArrayList<>(), new HashMap<>()));
                }

                // main fields
                dest = new Member(src.getId(), Member.Sex.getEnum(src.getSex()),
                        Member.AffectionStatus.getEnum(src.getPhenotype()));

                // attributes
                if (src.getSamples() != null && src.getSamples().size() > 0) {
                    Map<String, String> annotation = src.getSamples().get(0).getAnnotations();
                    if (annotation != null) {
                        Map<String, Object> variables = new HashMap<>();
                        for (String key: annotation.keySet()) {
                            if (key.equals(INDIVIDUAL_ID) || key.equals(INDIVIDUAL_FAMILY)
                                    || key.equals(INDIVIDUAL_FATHER) || key.equals(INDIVIDUAL_MOTHER)
                                    || key.equals(INDIVIDUAL_SEX) || key.equals(INDIVIDUAL_PHENOTYPE)) {
                                continue;
                            }
                            String fields[] = key.split(":");
                            if (fields.length > 1) {
                                switch (fields[1].toLowerCase()) {
                                    case "i":
                                        variables.put(fields[0], Integer.parseInt(annotation.get(key)));
                                        break;
                                    case "d":
                                        variables.put(fields[0], Double.parseDouble(annotation.get(key)));
                                        break;
                                    case "b":
                                        variables.put(fields[0], Boolean.parseBoolean(annotation.get(key)));
                                        break;
                                    default:
                                        variables.put(fields[0], annotation.get(key));
                                }
                            } else {
                                variables.put(fields[0], annotation.get(key));
                            }
                        }
                        dest.setAttributes(variables);
                    }
                }
                pedigreeMap.get(pedigreeName).getMembers().add(dest);
                individualMap.put(pedigreeName + "_" + dest.getName(), dest);
            }

            // second loop: setting fathers, mothers, partners and children
            for (org.opencb.biodata.models.metadata.Individual src: variantStudyMetadata.getIndividuals()) {
                // update father, mother and child
                Member father = individualMap.get(src.getFamily() + "_" + src.getFather());
                Member mother = individualMap.get(src.getFamily() + "_" + src.getMother());
                Member child = individualMap.get(src.getFamily() + "_" + src.getId());

                // setting father and children
                if (father != null) {
                    child.setFather(father);
                    if (father.getMultiples() == null) {
                        Multiples multiples = new Multiples().setType("children").setSiblings(new ArrayList<>());
                        father.setMultiples(multiples);
                    }
                    father.getMultiples().getSiblings().add(child.getName());
                }

                // setting mother and children
                if (mother != null) {
                    child.setMother(mother);
                    if (mother.getMultiples() == null) {
                        Multiples multiples = new Multiples().setType("children").setSiblings(new ArrayList<>());
                        mother.setMultiples(multiples);
                    }
                    mother.getMultiples().getSiblings().add(child.getName());
                }
            }

        }

        // create the list of Pedigree objects from the map
        return new ArrayList<>(pedigreeMap.values());
    }
57509
public java.util.List<String> getResourceIds() {
        if (resourceIds == null) {
            resourceIds = new com.amazonaws.internal.SdkInternalList<String>();
        }
        return resourceIds;
    }
39706
def get_study_items(results):
        """"""
        study_items = set()
        for obj in results:
            study_items.update(obj.study_items)
        return study_items
478740
public Stream<LsParticipant> getAllParticipants(int surveyId) throws LimesurveyRCException {
        LsApiBody.LsApiParams params = getParamsWithKey(surveyId);
        params.setStart(0);
        params.setLimit(-1);
        List<LsParticipant> participants = gson.fromJson(callRC(new LsApiBody("list_participants", params)), new TypeToken<List<LsParticipant>>() {
        }.getType());

        return participants.stream();
    }
944231
public static function fetch_all_available($courseid) {
        global $CFG, $DB;

        $result = array();
        $params = array($courseid);
        $sql = "SELECT go.*
                  FROM {grade_outcomes} go, {grade_outcomes_courses} goc
                 WHERE go.id = goc.outcomeid AND goc.courseid = ?
              ORDER BY go.id ASC";

        if ($datas = $DB->get_records_sql($sql, $params)) {
            foreach($datas as $data) {
                $instance = new grade_outcome();
                grade_object::set_properties($instance, $data);
                $result[$instance->id] = $instance;
            }
        }
        return $result;
    }
1332992
public function get_samples($sampleids) {
        global $DB;

        $enrolments = enrol_get_course_users(false, false, array(), $sampleids);

        // Some course enrolments.
        list($enrolsql, $params) = $DB->get_in_or_equal($sampleids, SQL_PARAMS_NAMED);

        $samplesdata = array();
        foreach ($enrolments as $userenrolmentid => $user) {

            $sampleid = $userenrolmentid;
            $samplesdata[$sampleid]['user_enrolments'] = (object)array(
                'id' => $user->ueid,
                'status' => $user->uestatus,
                'enrolid' => $user->ueenrolid,
                'userid' => $user->id,
                'timestart' => $user->uetimestart,
                'timeend' => $user->uetimeend,
                'modifierid' => $user->uemodifierid,
                'timecreated' => $user->uetimecreated,
                'timemodified' => $user->uetimemodified
            );
            unset($user->ueid);
            unset($user->uestatus);
            unset($user->ueenrolid);
            unset($user->uetimestart);
            unset($user->uetimeend);
            unset($user->uemodifierid);
            unset($user->uetimecreated);
            unset($user->uetimemodified);

            // Enrolment samples are grouped by the course they belong to, so all $sampleids belong to the same
            // course, $courseid and $coursemodinfo will only query the DB once and cache the course data in memory.
            $courseid = $this->get_sample_courseid($sampleid);
            $coursemodinfo = get_fast_modinfo($courseid);
            $coursecontext = \context_course::instance($courseid);

            $samplesdata[$sampleid]['course'] = $coursemodinfo->get_course();
            $samplesdata[$sampleid]['context'] = $coursecontext;
            $samplesdata[$sampleid]['user'] = $user;

            // Fill the cache.
            $this->samplecourses[$sampleid] = $coursemodinfo->get_course()->id;
        }

        $enrolids = array_keys($samplesdata);
        return array(array_combine($enrolids, $enrolids), $samplesdata);
    }
410417
def get_study_txt(self, goid):
        """"""
        if goid in self.go2res:
            res = self.go2res[goid]
            if res.study_items is not None:
                return self._get_item_str(res)
            else:
                return self.fmtres.format(study_count=res.study_count)
497625
public HashSet<String> getDataById(String id) throws IOException {
    if (idToVersion.containsKey(id)) {
      return get(id);
    } else {
      return null;
    }
  }
593890
def _get_filtered_study_ids(shard, include_aliases=False):
    """"""
    from peyotl.phylesystem.helper import DIGIT_PATTERN
    k = shard.get_doc_ids()
    if shard.has_aliases and (not include_aliases):
        x = []
        for i in k:
            if DIGIT_PATTERN.match(i) or ((len(i) > 1) and (i[-2] == '_')):
                pass
            else:
                x.append(i)
        return x
880886
public List<T> allResults() {
        List<T> results = null;
        if (response != null && response.size() > 0) {
            // We first calculate the total size needed
            int totalSize = allResultsSize();

            // We init the list and copy data
            results = new ArrayList<>(totalSize);
            for (QueryResult<T> queryResult : response) {
                results.addAll(queryResult.getResult());
            }
        }
        return results;
    }
1328735
public List<GitlabBuildVariable> getBuildVariables(Integer projectId)
            throws IOException {
        String tailUrl = GitlabProject.URL + "/" + projectId + GitlabBuildVariable.URL;
        GitlabBuildVariable[] variables = retrieve().to(tailUrl, GitlabBuildVariable[].class);
        return Arrays.asList(variables);
    }
523388
public void removeCohort(String cohortId, String studyId) {
        // Sanity check
        if (StringUtils.isEmpty(cohortId)) {
            logger.error("Cohort ID {} is null or empty.", cohortId);
            return;
        }

        VariantStudyMetadata variantStudyMetadata = getVariantStudyMetadata(studyId);
        if (variantStudyMetadata == null) {
            logger.error("Study not found. Check your study ID: '{}'", studyId);
            return;
        }
        if (variantStudyMetadata.getCohorts() != null) {
            for (int i = 0; i < variantStudyMetadata.getCohorts().size(); i++) {
                if (cohortId.equals(variantStudyMetadata.getCohorts().get(i).getId())) {
                    variantStudyMetadata.getCohorts().remove(i);
                    return;
                }
            }
        }
    }