code stringlengths 1 18.2k |
|---|
def _hardClip(sequence, quality, cigartuples): """ Hard clip (if necessary) a sequence. @param sequence: A C{str} nucleotide sequence. @param quality: A C{str} quality string, or a C{list} of C{int} quality values as returned by pysam, or C{None} if the SAM file had a '*' for the quality string (which pysam converts to... |
been done. """ hardClipCount = cigarLength = 0 for (operation, length) in cigartuples: hardClipCount += operation == CHARD_CLIP cigarLength += length if operation in _CONSUMES_QUERY else 0 sequenceLength = len(sequence) if quality is not None: assert sequenceLength == len(quality) clipLeft = clipRight = 0 clippedSequen... |
ValueError( 'Invalid CIGAR tuples (%s) contains hard-clipping operation ' 'that is neither at the start nor the end of the sequence.' % (cigartuples,)) elif hardClipCount == 2: # Hard clip at both the start and end. assert cigartuples[0][0] == cigartuples[-1][0] == CHARD_CLIP if not alreadyClipped: clipLeft, clipRight ... |
left and right clip lengths (%d and %d ' 'respectively). CIGAR tuples: %s' % (sequence, len(sequence), clippedSequence, len(clippedSequence), abs(len(sequence) - len(clippedSequence)), clipLeft + clipRight, clipLeft, clipRight, cigartuples)) else: assert len(clippedSequence) == sequenceLength if quality is not None: as... |
def addFilteringOptions(parser, samfileIsPositionalArg=False): """ Add options to an argument parser for filtering SAM/BAM. @param samfileIsPositionalArg: If C{True} the SAM/BAM file must be given as the final argument on the command line (without being preceded by --samfile). @param parser: An C{argparse.ArgumentParse... |
parser.add_argument( '--dropDuplicates', default=False, action='store_true', help=('If given, matches flagged as optical or PCR duplicates ' 'will not be output.')) parser.add_argument( '--keepQCFailures', default=False, action='store_true', help=('If given, reads that are considered quality control ' 'failures will be... |
def parseFilteringOptions(cls, args, filterRead=None, storeQueryIds=False): """ Parse command line options (added in C{addSAMFilteringOptions}. @param args: The command line arguments, as returned by C{argparse.parse_args}. @param filterRead: A one-argument function that accepts a read and returns C{None} if the read s... |
def alignments(self): """ Get alignments from the SAM/BAM file, subject to filtering. """ referenceIds = self.referenceIds dropUnmapped = self.dropUnmapped dropSecondary = self.dropSecondary dropSupplementary = self.dropSupplementary dropDuplicates = self.dropDuplicates keepQCFailures = self.keepQCFailures storeQueryId... |
# the previous sequence should be used. This is best # practice according to section 2.5.2 of # https://samtools.github.io/hts-specs/SAMv1.pdf So we use # the last alignment query and quality strings if we get # None as a query sequence. if alignment.query_sequence is None: if lastAlignment is None: raise InvalidSAM( '... |
aligned to something (i.e., it cannot be unmapped # with no CIGAR string). The assertion will tell us if # this is ever not the case. assert alignment.cigartuples (alignment.query_sequence, alignment.query_qualities, _) = _hardClip( lastAlignment.query_sequence, lastAlignment.query_qualities, alignment.cigartuples) els... |
def referenceLengths(self): """ Get the lengths of wanted references. @raise UnknownReference: If a reference id is not present in the SAM/BAM file. @return: A C{dict} of C{str} reference id to C{int} length with a key for each reference id in C{self.referenceIds} or for all references if C{self.referenceIds} is C{None... |
def queries(self, rcSuffix='', rcNeeded=False, padChar='-', queryInsertionChar='N', unknownQualityChar='!', allowDuplicateIds=False, addAlignment=False): """ Produce padded (with gaps) queries according to the CIGAR string and reference sequence length for each matching query sequence. @param rcSuffix: A C{str} to add ... |
them the same length as the reference sequence. @param queryInsertionChar: A C{str} of length one to use to insert into queries when the CIGAR string indicates that the alignment of a query would cause a deletion in the reference. This character is inserted as a 'missing' query character (i.e., a base that can be assum... |
in the yielded FASTA. @param addAlignment: If C{True} the reads yielded by the returned generator will also have an C{alignment} attribute, being the C{pysam.AlignedSegment} for the query. @raises InvalidSAM: If a query has an empty SEQ field and either there is no previous alignment or the alignment is not marked as s... |
query = alignment.query_sequence quality = ''.join(chr(q + 33) for q in alignment.query_qualities) if alignment.is_reverse: if rcNeeded: query = DNARead('id', query).reverseComplement().sequence quality = quality[::-1] if rcSuffix: alignment.query_name += rcSuffix # Adjust the query id if it's a duplicate and we're not... |
alignedSequence += query[queryIndex:queryIndex + length] alignedQuality += quality[queryIndex:queryIndex + length] elif operation == CINS: # Insertion to the reference. This consumes query bases but # we don't output them because the reference cannot be # changed. I.e., these bases in the query would need to be # inser... |
CREF_SKIP: # Skipped reference. Opens a gap in the query. For # mRNA-to-genome alignment, an N operation represents an # intron. For other types of alignments, the # interpretation of N is not defined. So this is unlikely # to occur. atStart = False alignedSequence += queryInsertionChar * length alignedQuality += unkno... |
= length - referenceStart if unwantedLeft > 0: # The query protrudes left. Copy its right part. alignedSequence += query[ queryIndex + unwantedLeft:queryIndex + length] alignedQuality += quality[ queryIndex + unwantedLeft:queryIndex + length] referenceStart = 0 else: referenceStart -= length alignedSequence += query[ q... |
first and/or last # operation. There is nothing to do as the bases are simply # not present in the query string in the SAM/BAM file. pass elif operation == CPAD: # This is "silent deletion from the padded reference", # which consumes neither query nor reference. atStart = False else: raise ValueError('Unknown CIGAR ope... |
the query but is silent # about the part of the reference that lies to the right of the # aligned query. # Put gap characters before and after the aligned sequence so that # it is offset properly and matches the length of the reference. padRightLength = (referenceLength - (referenceStart + len(alignedSequence))) padded... |
def mux(sel, ls_di, do): """ Multiplexes a list of input signals to an output signal do = sl_di[sel] sel - select index ls_di - list of input signals do - output signals """ N = len(ls_di) @always_comb def _mux(): do.next = 0 for i in range(N): if i == sel: do.next = ls_di[i] return _mux |
def demux(sel, di, ls_do): """ Demultiplexes an input signal to a list of output signals ls_do[sel] = di sel - select index di - input signal ls_do - list of output signals """ N = len(ls_do) @always_comb def _demux(): for i in range(N): ls_do[i].next = 0 if i == sel: ls_do[i].next = di return _demux |
def ls_mux(sel, lsls_di, ls_do): """ Multiplexes a list of input signal structures to an output structure. A structure is represented by a list of signals: [signal_1, signal_2, ..., signal_n] ls_do[0] = lsls_di[sel][0] ls_do[1] = lsls_di[sel][1] ... ls_do[n] = lsls_di[sel][n] sel - select index lsls_di - list of input ... |
def ls_demux(sel, ls_di, lsls_do): """ Demultiplexes an input signal structure to list of output structures. A structure is represented by a list of signals: [signal_1, signal_2, ..., signal_n] lsls_do[sel][0] = ls_di[0] lsls_do[sel][1] = ls_di[1] ... lsls_do[sel][n] = ls_di[n] sel - select index ls_di - input signal s... |
def bitslice_select(offset, bv_di, bv_do): ''' Selects a bit-slice from a bit-vector offset - (i) bit offset of the slice bv_di - (i) bit vector where the slice is taken from bv_do - (o) selected slice; the length of this bit-vector defines the number of bit in the slice bv_do = bv_di[len(bv_do)+offset:offset] ''' LEN_... |
def byteslice_select(offset, bv_di, bv_do): ''' Selects a slice of length 8*n aligned on a byte from a bit-vector offset - (i) byte offset of the slice bv_di - (i) bit vector where the slice is taken from; must len(bv_di) = 8*m bv_do - (o) selected slice; must len(bv_do) = 8*n, n<=m; len(bv_do) defines the number of bi... |
def get_argument_parser(): """Function to obtain the argument parser. Returns ------- A fully configured `argparse.ArgumentParser` object. Notes ----- This function is used by the `sphinx-argparse` extension for sphinx. """ file_mv = cli.file_mv desc = 'Find all runs (SRR..) associated with an SRA experiment (SRX...).'... |
def main(args=None): """Download all .sra from NCBI SRA for a given experiment ID. Parameters ---------- args: argparse.Namespace object, optional The argument values. If not specified, the values will be obtained by parsing the command line arguments using the `argparse` module. Returns ------- int Exit code (0 if no ... |
ftputil.FTPHost(host, user, password) as ftp_host: for exp in experiments: exp_dir = '/sra/sra-instant/reads/ByExp/sra/SRX/%s/%s/' \ % (exp[:6], exp) ftp_host.chdir(exp_dir) run_folders = ftp_host.listdir(ftp_host.curdir) # logging.info('Found %d run folders.',len(run_folders)) for folder in run_folders: files = ftp_ho... |
def _one_to_many_query(cls, query_obj, search4, model_attrib): """extends and returns a SQLAlchemy query object to allow one-to-many queries :param query_obj: SQL Alchemy query object :param str search4: search string :param model_attrib: attribute in model """ model = model_attrib.parent.class_ if isinstance(search4, ... |
def keyword(self, name=None, identifier=None, entry_name=None, limit=None, as_df=False): """Method to query :class:`.models.Keyword` objects in database :param name: keyword name(s) :type name: str or tuple(str) or None :param identifier: keyword identifier(s) :type identifier: str or tuple(str) or None :param entry_na... |
return self._limit_and_df(q, limit, as_df) |
def entry(self, name=None, dataset=None, recommended_full_name=None, recommended_short_name=None, gene_name=None, taxid=None, accession=None, organism_host=None, feature_type=None, function_=None, ec_number=None, db_reference=None, alternative_name=None, disease_comment=None, disease_name=None, tissue_specificity=None,... |
:type keyword: str or tuple(str) or None :param pmid: PubMed identifier(s) :type pmid: int or tuple(int) or None :param tissue_specificity: tissue specificit(y/ies) :type tissue_specificity: str or tuple(str) or None :param disease_comment: disease_comment(s) :type disease_comment: str or tuple(str) or None :param alte... |
name(s) :type disease_name: str or tuple(str) or None :param gene_name: gene name(s) :type gene_name: str or tuple(str) or None :param taxid: NCBI taxonomy identifier(s) :type taxid: int or tuple(int) or None :param sequence: Amino acid sequence(s) :type sequence: str or tuple(str) or None :param limit: - if `isinstanc... |
(accession, models.Accession.accession), (organism_host, models.OrganismHost.taxid), (feature_type, models.Feature.type_), (function_, models.Function.text), (ec_number, models.ECNumber.ec_number), (db_reference, models.DbReference.identifier), (alternative_name, models.AlternativeFullName.name), (disease_comment, mode... |
def disease(self, identifier=None, ref_id=None, ref_type=None, name=None, acronym=None, description=None, entry_name=None, limit=None, as_df=False ): """Method to query :class:`.models.Disease` objects in database :param identifier: disease UniProt identifier(s) :type identifier: str or tuple(str) or None :param ref_id... |
None :param bool as_df: if `True` results are returned as :class:`pandas.DataFrame` :return: - if `as_df == False` -> list(:class:`.models.Disease`) - if `as_df == True` -> :class:`pandas.DataFrame` :rtype: list(:class:`.models.Disease`) or :class:`pandas.DataFrame` """ q = self.session.query(models.Disease) model_quer... |
def disease_comment(self, comment=None, entry_name=None, limit=None, as_df=False): """Method to query :class:`.models.DiseaseComment` objects in database :param comment: Comment(s) to disease :type comment: str or tuple(str) or None :param entry_name: name(s) in :class:`.models.Entry` :type entry_name: str or tuple(str... |
def other_gene_name(self, type_=None, name=None, entry_name=None, limit=None, as_df=None): """Method to query :class:`.models.OtherGeneName` objects in database :param type_: type(s) of gene name e.g. *synonym* :type type_: str or tuple(str) or None :param name: other gene name(s) :type name: str or tuple(str) or None ... |
= self.get_one_to_many_queries(q, ((entry_name, models.Entry.name),)) return self._limit_and_df(q, limit, as_df) |
def alternative_full_name(self, name=None, entry_name=None, limit=None, as_df=False): """Method to query :class:`.models.AlternativeFullName` objects in database :param name: alternative full name(s) :type name: str or tuple(str) or None :param entry_name: name(s) in :class:`.models.Entry` :type entry_name: str or tupl... |
def alternative_short_name(self, name=None, entry_name=None, limit=None, as_df=False): """Method to query :class:`.models.AlternativeShortlName` objects in database :param name: alternative short name(s) :type name: str or tuple(str) or None :param entry_name: name(s) in :class:`.models.Entry` :type entry_name: str or ... |
def accession(self, accession=None, entry_name=None, limit=None, as_df=False): """Method to query :class:`.models.Accession` objects in database :param accession: UniProt Accession number(s) :type accession: str or tuple(str) or None :param entry_name: name(s) in :class:`.models.Entry` :type entry_name: str or tuple(st... |
def pmid(self, pmid=None, entry_name=None, first=None, last=None, volume=None, name=None, date=None, title=None, limit=None, as_df=False ): """Method to query :class:`.models.Pmid` objects in database :param pmid: PubMed identifier(s) :type pmid: int or tuple(int) or None :param entry_name: name(s) in :class:`.models.E... |
None -> all results :type limit: int or tuple(int) or None :param bool as_df: if `True` results are returned as :class:`pandas.DataFrame` :return: - if `as_df == False` -> list(:class:`.models.Pmid`) - if `as_df == True` -> :class:`pandas.DataFrame` :rtype: list(:class:`.models.Pmid`) or :class:`pandas.DataFrame` """ q... |
def organism_host(self, taxid=None, entry_name=None, limit=None, as_df=False): """Method to query :class:`.models.OrganismHost` objects in database :param taxid: NCBI taxonomy identifier(s) :type taxid: int or tuple(int) or None :param entry_name: name(s) in :class:`.models.Entry` :type entry_name: str or tuple(str) or... |
def db_reference(self, type_=None, identifier=None, entry_name=None, limit=None, as_df=False): """Method to query :class:`.models.DbReference` objects in database Check list of available databases with on :py:attr:`.dbreference_types` :param type_: type(s) (or name(s)) of database :type type_: str or tuple(str) or None... |
= self.session.query(models.DbReference) model_queries_config = ( (type_, models.DbReference.type_), (identifier, models.DbReference.identifier) ) q = self.get_model_queries(q, model_queries_config) q = self.get_one_to_many_queries(q, ((entry_name, models.Entry.name),)) return self._limit_and_df(q, limit, as_df) |
def feature(self, type_=None, identifier=None, description=None, entry_name=None, limit=None, as_df=False): """Method to query :class:`.models.Feature` objects in database Check available features types with ``pyuniprot.query().feature_types`` :param type_: type(s) of feature :type type_: str or tuple(str) or None :par... |
= self.session.query(models.Feature) model_queries_config = ( (type_, models.Feature.type_), (identifier, models.Feature.identifier), (description, models.Feature.description) ) q = self.get_model_queries(q, model_queries_config) q = self.get_one_to_many_queries(q, ((entry_name, models.Entry.name),)) return self._limit... |
def function(self, text=None, entry_name=None, limit=None, as_df=False): """Method to query :class:`.models.Function` objects in database :param text: description(s) of function(s) :type text: str or tuple(str) or None :param entry_name: name(s) in :class:`.models.Entry` :type entry_name: str or tuple(str) or None :par... |
def ec_number(self, ec_number=None, entry_name=None, limit=None, as_df=False): """Method to query :class:`.models.ECNumber` objects in database :param ec_number: Enzyme Commission number(s) :type ec_number: str or tuple(str) or None :param entry_name: name(s) in :class:`.models.Entry` :type entry_name: str or tuple(str... |
def subcellular_location(self, location=None, entry_name=None, limit=None, as_df=False): """Method to query :class:`.models.SubcellularLocation` objects in database :param location: subcellular location(s) :type location: str or tuple(str) or None :param entry_name: name(s) in :class:`.models.Entry` :type entry_name: s... |
def tissue_specificity(self, comment=None, entry_name=None, limit=None, as_df=False): """Method to query :class:`.models.TissueSpecificity` objects in database Provides information on the expression of a gene at the mRNA or protein level in cells or in tissues of multicellular organisms. By default, the information is ... |
True` -> :class:`pandas.DataFrame` :rtype: list(:class:`.models.TissueSpecificity`) or :class:`pandas.DataFrame` """ q = self.session.query(models.TissueSpecificity) q = self.get_model_queries(q, ((comment, models.TissueSpecificity.comment),)) q = self.get_one_to_many_queries(q, ((entry_name, models.Entry.name),)) retu... |
def tissue_in_reference(self, tissue=None, entry_name=None, limit=None, as_df=False): """Method to query :class:`.models.TissueInReference` objects in database :param tissue: tissue(s) linked to reference :type tissue: str or tuple(str) or None :param entry_name: name(s) in :class:`.models.Entry` :type entry_name: str ... |
def dbreference_types(self): """Distinct database reference types (``type_``) in :class:`.models.DbReference` :return: List of strings for all available database cross reference types used in model DbReference :rtype: list[str] """ q = self.session.query(distinct(models.DbReference.type_)) return [x[0] for x in q.all()... |
def taxids(self): """Distinct NCBI taxonomy identifiers (``taxid``) in :class:`.models.Entry` :return: NCBI taxonomy identifiers :rtype: list[int] """ r = self.session.query(distinct(models.Entry.taxid)).all() return [x[0] for x in r] |
def datasets(self): """Distinct datasets (``dataset``) in :class:`.models.Entry` Distinct datasets are SwissProt or/and TrEMBL :return: all distinct dataset types :rtype: list[str] """ r = self.session.query(distinct(models.Entry.dataset)).all() return [x[0] for x in r] |
def feature_types(self): """Distinct types (``type_``) in :class:`.models.Feature` :return: all distinct feature types :rtype: list[str] """ r = self.session.query(distinct(models.Feature.type_)).all() return [x[0] for x in r] |
def subcellular_locations(self): """Distinct subcellular locations (``location`` in :class:`.models.SubcellularLocation`) :return: all distinct subcellular locations :rtype: list[str] """ return [x[0] for x in self.session.query(models.SubcellularLocation.location).all()] |
def tissues_in_references(self): """Distinct tissues (``tissue`` in :class:`.models.TissueInReference`) :return: all distinct tissues in references :rtype: list[str] """ return [x[0] for x in self.session.query(models.TissueInReference.tissue).all()] |
def keywords(self): """Distinct keywords (``name`` in :class:`.models.Keyword`) :returns: all distinct keywords :rtype: list[str] """ return [x[0] for x in self.session.query(models.Keyword.name).all()] |
def diseases(self): """Distinct diseases (``name`` in :class:`.models.Disease`) :returns: all distinct disease names :rtype: list[str] """ return [x[0] for x in self.session.query(models.Disease.name).all()] |
def version(self): """Version of UniPort knowledgebase :returns: dictionary with version info :rtype: dict """ return [x for x in self.session.query(models.Version).all()] |
def reserve(self, force=False): """ Reserve port. :param force: True - take forcefully, False - fail if port is reserved by other user """ if not force: try: self.api.call_rc('ixPortTakeOwnership {}'.format(self.uri)) except Exception as _: raise TgnError('Failed to take ownership for port {} current owner is {}'.forma... |
def write(self): """ Write configuration to chassis. Raise StreamWarningsError if configuration warnings found. """ self.ix_command('write') stream_warnings = self.streamRegion.generateWarningList() warnings_list = (self.api.call('join ' + ' {' + stream_warnings + '} ' + ' LiStSeP').split('LiStSeP') if self.streamRegio... |
def load_config(self, config_file_name): """ Load configuration file from prt or str. Configuration file type is extracted from the file suffix - prt or str. :param config_file_name: full path to the configuration file. IxTclServer must have access to the file location. either: The config file is on shared folder. IxTc... |
def save_config(self, config_file_name): """ Save configuration file from prt or str. Configuration file type is extracted from the file suffix - prt or str. :param config_file_name: full path to the configuration file. IxTclServer must have access to the file location. either: The config file is on shared folder. IxTc... |
def start_transmit(self, blocking=False): """ Start transmit on port. :param blocking: True - wait for traffic end, False - return after traffic start. """ self.session.start_transmit(blocking, False, self) |
def stop_capture(self, cap_file_name=None, cap_file_format=IxeCapFileFormat.mem): """ Stop capture on port. :param cap_file_name: prefix for the capture file name. Capture file will be saved as pcap file named 'prefix' + 'URI'.pcap. :param cap_file_format: exported file format :return: number of captured frames """ ret... |
def get_cap_frames(self, *frame_nums): """ Stop capture on ports. :param frame_nums: list of frame numbers to read. :return: list of captured frames. """ frames = [] for frame_num in frame_nums: if self.captureBuffer.getframe(frame_num) == '0': frames.append(self.captureBuffer.frame) else: frames.append(None) return fr... |
def clear_port_stats(self): """ Clear only port stats (leave stream and packet group stats). Do not use - still working with Ixia to resolve. """ stat = IxeStat(self) stat.ix_set_default() stat.enableValidStats = True stat.ix_set() stat.write() |
def set_phy_mode(self, mode=IxePhyMode.ignore): """ Set phy mode to copper or fiber. :param mode: requested PHY mode. """ if isinstance(mode, IxePhyMode): if mode.value: self.api.call_rc('port setPhyMode {} {}'.format(mode.value, self.uri)) else: self.api.call_rc('port setPhyMode {} {}'.format(mode, self.uri)) |
def set_transmit_mode(self, mode): """ set port transmit mode :param mode: request transmit mode :type mode: ixexplorer.ixe_port.IxeTransmitMode """ self.api.call_rc('port setTransmitMode {} {}'.format(mode, self.uri)) |
def get_image_sizes(image): """Given an ImageField `image`, returns a list of images sizes in this form: [ { "url": "http://example.com/xxx.jpg", "width": 1440, "height": 960 }, [...] ]""" # It is possible to have the same width appear more than once, if # THUMBNAIL_UPSCALE is set to False and the image's width is less... |
def get_template_context(src, container="div", classes="", inner_classes="", alt="", background_image=False, no_css=False, aria_hidden=False): """Returns a template context for a flexible image template tag implementation.""" context = { "container": container, "classes": classes, "aspect_padding_bottom": aspect_ratio_... |
def fit(self, images, reference=None): """ Estimate registration model using cross-correlation. Use cross correlation to compute displacements between images or volumes and reference. Displacements will be 2D for images and 3D for volumes. Parameters ---------- images : array-like or thunder images The sequence of imag... |
def fit_and_transform(self, images, reference=None): """ Estimate and apply registration model using cross-correlation. Use cross correlation to compute displacements between images or volumes and reference, and apply the estimated model to the data. Displacements will be 2D for images and 3D for volumes. Parameters --... |
def build_path(entities, path_patterns, strict=False): """ Constructs a path given a set of entities and a list of potential filename patterns to use. Args: entities (dict): A dictionary mapping entity names to entity values. path_patterns (str, list): One or more filename patterns to write the file to. Entities should... |
2: 'sub-01/var-SES/1045.csv' strict (bool): If True, all passed entities must be matched inside a pattern in order to be a valid match. If False, extra entities will be ignored so long as all mandatory entities are found. Returns: A constructed path for this file based on the provided patterns. """ if isinstance(path_p... |
% optional_pattern, optional_chunk) # Replace remaining entities new_path = replace_entities(entities, new_path) if new_path: return new_path return None |
def get_settings_from_environment(environ): '''Deduce settings from environment variables''' settings = {} for name, value in environ.items(): if not name.startswith('DJANGO_'): continue name = name.replace('DJANGO_', '', 1) if _ignore_setting(name): continue try: settings[name] = ast.literal_eval(value) except (Syntax... |
def vmc_digest(data, digest_size=DEFAULT_DIGEST_SIZE): """Returns the VMC Digest as a Digest object, which has both bytes and str ( URL-safe, Base 64) representations. >>> d = vmc_digest("") # I can't figure out how to make this test work on Py 2 and 3 :-( >>> d # doctest: +SKIP b'\xcf\x83\xe15~\xef\xb8\xbd\xf1T(P\xd6m... |
performance implications. By truncating the SHA-512 digest [1], users may obtain a tunable level of collision avoidance. The string returned by this function is Base 64 encoded with URL-safe characters [2], making it suitable for use with URLs or filesystem paths. Base 64 encoding results in an output string that is 4/... |
on the number of messages, but not their size. Solving for the number of messages: m(b, P) = sqrt(P * 2^(b+1)) Solving for the number of *bits*: b(m, P) = log2(m^2/P) - 1 For various values of m and P, the number of *bytes* required according to b(m,P) rounded to next multiple of 3 is: +-------+----------+----------+--... |
12 | 12 | | 1e+18 | 18 | 18 | 15 | 15 | 15 | 12 | | 1e+21 | 21 | 18 | 18 | 15 | 15 | 15 | | 1e+24 | 21 | 21 | 18 | 18 | 15 | 15 | +-------+----------+----------+----------+----------+----------+----------+ For example, given 1e+18 expected messages and a desired collision probability < 1e-15, we use digest_size = 15 (b... |
def filter_variance(matrix, top): """Filter genes in an expression matrix by variance. Parameters ---------- matrix: ExpMatrix The expression matrix. top: int The number of genes to retain. Returns ------- ExpMatrix The filtered expression matrix. """ assert isinstance(matrix, ExpMatrix) assert isinstance(top, (int, np... |
matrix |
def filter_mean(matrix, top): """Filter genes in an expression matrix by mean expression. Parameters ---------- matrix: ExpMatrix The expression matrix. top: int The number of genes to retain. Returns ------- ExpMatrix The filtered expression matrix. """ assert isinstance(matrix, ExpMatrix) assert isinstance(top, int) ... |
def filter_percentile(matrix, top, percentile=50): """Filter genes in an expression matrix by percentile expression. Parameters ---------- matrix: ExpMatrix The expression matrix. top: int The number of genes to retain. percentile: int or float, optinonal The percentile to use Defaults to the median (50th percentile). ... |
def _transform_chrom(chrom): """Helper function to obtain specific sort order.""" try: c = int(chrom) except: if chrom in ['X', 'Y']: return chrom elif chrom == 'MT': return '_MT' # sort to the end else: return '__' + chrom # sort to the very end else: # make sure numbered chromosomes are sorted numerically return '%02... |
def get_chromosome_lengths(fasta_file, fancy_sort=True): """Extract chromosome lengths from genome FASTA file.""" chromlen = [] with gzip.open(fasta_file, 'rt', encoding='ascii') as fh: fasta = SeqIO.parse(fh, 'fasta') for i, f in enumerate(fasta): chromlen.append((f.id, len(f.seq))) _LOGGER.info('Processed chromosome ... |
def resolve_schema(schema): """Transform JSON schemas "allOf". This is the default schema resolver. This function was created because some javascript JSON Schema libraries don't support "allOf". We recommend to use this function only in this specific case. This function is transforming the JSON Schema by removing "allO... |
None) schema = _merge_dicts(schema, sub_schema) schema.pop('allOf') schema = traverse(schema) elif 'properties' in schema: for x in schema.get('properties', []): schema['properties'][x] = traverse( schema['properties'][x]) elif 'items' in schema: schema['items'] = traverse(schema['items']) return schema return traverse... |
def _merge_dicts(first, second): """Merge the 'second' multiple-dictionary into the 'first' one.""" new = deepcopy(first) for k, v in second.items(): if isinstance(v, dict) and v: ret = _merge_dicts(new.get(k, dict()), v) new[k] = ret else: new[k] = second[k] return new |
def read_colorscale(cmap_file): """Return a colorscale in the format expected by plotly. Parameters ---------- cmap_file : str Path of a plain-text file containing the colorscale. Returns ------- list The colorscale. Notes ----- A plotly colorscale is a list where each item is a pair (i.e., a list with two elements) co... |
i in range(n): colorscale.append( [i / float(n - 1), 'rgb(%d, %d, %d)' % (rgb[i, 0], rgb[i, 1], rgb[i, 2])] ) return colorscale |
def make_router(): """Return a WSGI application that searches requests to controllers """ global router routings = [ ('GET', '^/$', index), ('GET', '^/api/?$', index), ('POST', '^/api/1/calculate/?$', calculate.api1_calculate), ('GET', '^/api/2/entities/?$', entities.api2_entities), ('GET', '^/api/1/field/?$', field.ap... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.