Returns the next ReferenceAnalysesGroupID for the given reference
            sample. Gets the last reference analysis registered in the system
            for the specified reference sample and increments in one unit the
            suffix.
512104
def nextRefAnalysesGroupID(self, reference):
        
        prefix = reference.id + "-"
        if not IReferenceSample.providedBy(reference):
            # Not a ReferenceSample, so this is a duplicate
            prefix = reference.id + "-D"
        bac = getToolByName(reference, 'bika_analysis_catalog')
        ids = bac.Indexes['getReferenceAnalysesGroupID'].uniqueValues()
        rr = re.compile("^" + prefix + "[\d+]+$")
        ids = [int(i.split(prefix)[1]) for i in ids if i and rr.match(i)]
        ids.sort()
        _id = ids[-1] if ids else 0
        suffix = str(_id + 1).zfill(int(3))
        if not IReferenceSample.providedBy(reference):
            # Not a ReferenceSample, so this is a duplicate
            suffix = str(_id + 1).zfill(2)
        return '%s%s' % (prefix, suffix)
371645
def _reference_getter(table):
    
    from google.cloud.bigquery import dataset

    dataset_ref = dataset.DatasetReference(table.project, table.dataset_id)
    return TableReference(dataset_ref, table.table_id)
1330755
def _next_sample_index(self):
        
        return self.rng.choice(self.n_streams,
                               p=(self.stream_weights_ /
                                  self.weight_norm_))
656785
def reference_id_parts(reference_id):
    
    m = consts.REFERENCE_ID_PATTERN.match(reference_id)
    if m:
        return m.groups()
    raise ValueError('Illegal reference identifier: "%s"' % reference_id)
812858
private AbstractPlanNode indexAccessForGroupByExprs(SeqScanPlanNode root,
            IndexGroupByInfo gbInfo) {
        if (! root.isPersistentTableScan()) {
            // subquery and common tables are not handled
            return root;
        }

        String fromTableAlias = root.getTargetTableAlias();
        assert(fromTableAlias != null);

        List<ParsedColInfo> groupBys = m_parsedSelect.groupByColumns();
        Table targetTable = m_catalogDb.getTables().get(root.getTargetTableName());
        assert(targetTable != null);
        CatalogMap<Index> allIndexes = targetTable.getIndexes();

        List<Integer> maxCoveredGroupByColumns = new ArrayList<>();
        ArrayList<AbstractExpression> maxCoveredBindings = null;
        Index pickedUpIndex = null;
        boolean foundAllGroupByCoveredIndex = false;

        for (Index index : allIndexes) {
            if ( ! IndexType.isScannable(index.getType())) {
                continue;
            }

            if ( ! index.getPredicatejson().isEmpty()) {
                // do not try to look at Partial/Sparse index
                continue;
            }

            ArrayList<AbstractExpression> bindings = new ArrayList<>();
            List<Integer> coveredGroupByColumns = calculateGroupbyColumnsCovered(
                    index, fromTableAlias, bindings);

            if (coveredGroupByColumns.size() > maxCoveredGroupByColumns.size()) {
                maxCoveredGroupByColumns = coveredGroupByColumns;
                pickedUpIndex = index;
                maxCoveredBindings = bindings;

                if (maxCoveredGroupByColumns.size() == groupBys.size()) {
                    foundAllGroupByCoveredIndex = true;
                    break;
                }
            }
        }
        if (pickedUpIndex == null) {
            return root;
        }

        IndexScanPlanNode indexScanNode = new IndexScanPlanNode(
                root, null, pickedUpIndex, SortDirectionType.INVALID);
        indexScanNode.setForGroupingOnly();
        indexScanNode.setBindings(maxCoveredBindings);

        gbInfo.m_coveredGroupByColumns = maxCoveredGroupByColumns;
        gbInfo.m_canBeFullySerialized = foundAllGroupByCoveredIndex;
        return indexScanNode;
    }
1173291
def get_service_uid_from(self, analysis):
        
        analysis = api.get_object(analysis)
        return api.get_uid(analysis.getAnalysisService())
362616
String lookupPid(ConfigID referenceId) {
        ExtendedConfiguration config = caSupport.lookupConfiguration(referenceId);
        String pid = (config == null) ? null : config.getPid();
        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
            Tr.debug(tc, "lookupPid(): Lookup of " + referenceId + " reference resolved to " + pid);
        }
        return pid;
    }
909617
public Subscription getSubscription(Reference reference) {
		return getResourceFactory().getApiResource(
				"/subscription/" + reference.toURLFragment(false)).get(
				Subscription.class);
	}
51107
private Group getNewGroup(String recordName,Character aminoCode1, String aminoCode3) {

		Group g =  ChemCompGroupFactory.getGroupFromChemCompDictionary(aminoCode3);
		if ( g != null && !g.getChemComp().isEmpty())
			return g;


		Group group;
		if (aminoCode1 == null || StructureTools.UNKNOWN_GROUP_LABEL == aminoCode1 ){
			group = new HetatomImpl();

		} else if(StructureTools.isNucleotide(aminoCode3))  {
			// it is a nucleotide
			NucleotideImpl nu = new NucleotideImpl();
			group = nu;

		} else {
			AminoAcidImpl aa = new AminoAcidImpl() ;
			aa.setAminoType(aminoCode1);
			group = aa ;
		}

		//		System.out.println("new resNum type: "+ resNum.getType() );
		return  group ;
	}
670816
def _analyze_single(self, reference, result):
        ''''''
        # TODO: Recalculate coverage based on reference (e.g. sequencing result
        # longer than template
        reference_str = str(reference)
        result_str = str(result)
        report = {'mismatches': [], 'insertions': [], 'deletions': []}
        for i, (ref, res) in enumerate(zip(reference_str, result_str)):
            if ref != res:
                # It's a mismatch or indel
                if ref == '-':
                    report['insertions'].append(i)
                if res == '-':
                    report['deletions'].append(i)
                else:
                    report['mismatches'].append(i)

        start = len(result_str) - len(result_str.lstrip('-'))
        stop = len(result_str) - len(result_str.rstrip('-'))
        report['coverage'] = [start, stop]

        return report
1201513
def getrmlsthelper(referencefilepath, update, start):
    
    from subprocess import call
    analysistype = 'rMLST'
    # Folders are named based on the download date e.g 2016-04-26
    # Find all folders (with the trailing / in the glob search) and remove the trailing /
    lastfolder = sorted(glob('{}{}/*/'.format(referencefilepath, analysistype)))[-1].rstrip('/')
    # lastfolder = os.path.join(referencefilepath, analysistype)
    delta, foldersize, d1 = schemedate(lastfolder)
    # Extract the path of the current script from the full path + file name
    homepath = os.path.split(os.path.abspath(__file__))[0]
    # Set the path/name of the folder to contain the new alleles and profile
    newfolder = os.path.join(referencefilepath, analysistype, str(d1))
    # System call
    rmlstupdatecall = 'cd {} && perl {}/rest_auth.pl -a {}/secret.txt'.format(newfolder, homepath, homepath)
    if update:
        if delta.days > 7 or foldersize < 100:
            printtime("Last update of rMLST profile and alleles was {} days ago. Updating".format(str(delta.days)),
                      start)
            # Create the path
            make_path(newfolder)
            # Copy over the access token to be used in the authentication
            shutil.copyfile('{}/access_token'.format(homepath), '{}/access_token'.format(newfolder))
            # Run rest_auth.pl
            call(rmlstupdatecall, shell=True)
            # Get the new alleles into a list, and create the combinedAlleles file
            alleles = glob('{}/*.tfa'.format(newfolder))
            combinealleles(start, newfolder, alleles)
        # If the profile and alleles are up-to-date, set :newfolder to :lastfolder
        else:
            newfolder = lastfolder
        # Ensure that the profile/alleles updated successfully
        # Calculate the size of the folder by adding the sizes of all the files within the folder together
        newfoldersize = sum(os.path.getsize('{}/{}'.format(newfolder, f)) for f in os.listdir(newfolder)
                            if os.path.isfile('{}/{}'.format(newfolder, f)))
        # If the profile/allele failed, remove the folder, and use the most recent update
        if newfoldersize < 100:
            shutil.rmtree(newfolder)
            newfolder = sorted(glob('{}{}/*/'.format(referencefilepath, analysistype)))[-1].rstrip('/')
    # Don't update the profile/alleles if not requested
    else:
        newfolder = lastfolder
    # Return the system call and the folder containing the profile and alleles
    return rmlstupdatecall, newfolder
838621
def find_by_reference_ids(reference_ids, _connection=None, page_size=100,
        page_number=0, sort_by=enums.DEFAULT_SORT_BY,
        sort_order=enums.DEFAULT_SORT_ORDER):
        
        if not isinstance(reference_ids, (list, tuple)):
            err = "Video.find_by_reference_ids expects an iterable argument"
            raise exceptions.PyBrightcoveError(err)
        ids = ','.join(reference_ids)
        return connection.ItemResultSet(
            'find_videos_by_reference_ids', Video, _connection, page_size,
            page_number, sort_by, sort_order, reference_ids=ids)
1028867
def get_frip(self, sample):
        
        import pandas as pd
        with open(sample.frip, "r") as handle:
            content = handle.readlines()
        reads_in_peaks = int(re.sub("\D", "", content[0]))
        mapped_reads = sample["readCount"] - sample["unaligned"]
        return pd.Series(reads_in_peaks / mapped_reads, index="FRiP")
1095611
def component ref
    self.all_series.collect { |c| c if c.persistentId == ref }.compact.first
  end
511789
def find_by_reference_ids(reference_ids, connection=None, page_size=100,
        page_number=0, sort_by=DEFAULT_SORT_BY, sort_order=DEFAULT_SORT_ORDER):
        
        reference_ids = ','.join([str(i) for i in reference_ids])
        return pybrightcove.connection.ItemResultSet(
            "find_playlists_by_reference_ids", Playlist, connection, page_size,
            page_number, sort_by, sort_order, reference_ids=reference_ids)
1088588
def siblingsId(self) -> Tuple[CtsReference, CtsReference]:
        

        if not self._text:
            raise MissingAttribute("CapitainsCtsPassage was iniated without CtsTextMetadata object")
        if self._prev_next is not None:
            return self._prev_next

        document_references = self._text.getReffs(level=self.depth)

        range_length = 1
        if self.reference.is_range():
            range_length = len(self.getReffs())

        start = document_references.index(self.reference.start)

        if start == 0:
            # If the passage is already at the beginning
            _prev = None
        elif start - range_length < 0:
            _prev = document_references[0]
        else:
            _prev = document_references[start - 1]

        if start + 1 == len(document_references):
            # If the passage is already at the end
            _next = None
        elif start + range_length > len(document_references):
            _next = document_references[-1]
        else:
            _next = document_references[start + 1]

        self._prev_next = (_prev, _next)
        return self._prev_next
1203431
def next_group_id
        if @groups.empty?
          # Start each time from 1 to make sure groups get the same id's for the
          # same input data
          1
        else
          id = @groups.last.id
          loop do
            id += 1
            break id if @groups.find { |g| g.id == id }.nil?
          end
        end
      end