_id
stringlengths
2
7
title
stringlengths
1
88
partition
stringclasses
3 values
text
stringlengths
75
19.8k
language
stringclasses
1 value
meta_information
dict
q37900
_stage_ctrl
train
def _stage_ctrl(rst, clk, rx_rdy, rx_vld, tx_rdy, tx_vld, stage_en, stop_rx=None, stop_tx=None, BC=False): ''' Single stage control BC - enable bubble compression ''' if stop_rx==None: stop_rx = False if stop_tx==None: stop_tx = False state = Signal(bool(0)) a = Sig...
python
{ "resource": "" }
q37901
_sanityCheck
train
def _sanityCheck(subjectStart, subjectEnd, queryStart, queryEnd, queryStartInSubject, queryEndInSubject, hsp, queryLen, subjectGaps, queryGaps, localDict): """ Perform some sanity checks on an HSP. Call _debugPrint on any error. @param subjectStart: The 0-based C{int} star...
python
{ "resource": "" }
q37902
get_compute_credentials
train
def get_compute_credentials(key): """Authenticates a service account for the compute engine. This uses the `oauth2client.service_account` module. Since the `google` Python package does not support the compute engine (yet?), we need to make direct HTTP requests. For that we need authentication tokens. O...
python
{ "resource": "" }
q37903
ExpGeneTable.hash
train
def hash(self): """Generate a hash value.""" h = hash_pandas_object(self, index=True) return hashlib.md5(h.values.tobytes()).hexdigest()
python
{ "resource": "" }
q37904
ExpGeneTable.genes
train
def genes(self): """Return a list of all genes.""" return [ExpGene.from_series(g) for i, g in self.reset_index().iterrows()]
python
{ "resource": "" }
q37905
ExpGeneTable.read_tsv
train
def read_tsv(cls, file_or_buffer: str): """Read genes from tab-delimited text file.""" df = pd.read_csv(file_or_buffer, sep='\t', index_col=0) df = df.where(pd.notnull(df), None) # Note: df.where(..., None) changes all column types to `object`. return cls(df)
python
{ "resource": "" }
q37906
ExpGeneTable.from_genes
train
def from_genes(cls, genes: List[ExpGene]): """Initialize instance using a list of `ExpGene` objects.""" data = [g.to_dict() for g in genes] index = [d.pop('ensembl_id') for d in data] table = cls(data, index=index) return table
python
{ "resource": "" }
q37907
ExpGeneTable.from_gene_ids
train
def from_gene_ids(cls, gene_ids: List[str]): """Initialize instance from gene IDs.""" genes = [ExpGene(id_) for id_ in gene_ids] return cls.from_genes(genes)
python
{ "resource": "" }
q37908
ExpGeneTable.from_gene_ids_and_names
train
def from_gene_ids_and_names(cls, gene_names: Dict[str, str]): """Initialize instance from gene IDs and names.""" genes = [ExpGene(id_, name=name) for id_, name in gene_names.items()] return cls.from_genes(genes)
python
{ "resource": "" }
q37909
copy
train
def copy(src, trg, transform=None): ''' copy items with optional fields transformation ''' source = open(src[0], src[1]) target = open(trg[0], trg[1], autocommit=1000) for item in source.get(): item = dict(item) if '_id' in item: del item['_id'] if transform: ...
python
{ "resource": "" }
q37910
_regexp
train
def _regexp(expr, item): ''' REGEXP function for Sqlite ''' reg = re.compile(expr) return reg.search(item) is not None
python
{ "resource": "" }
q37911
Storage._dict_factory
train
def _dict_factory(cursor, row): ''' factory for sqlite3 to return results as dict ''' d = {} for idx, col in enumerate(cursor.description): if col[0] == 'rowid': d['_id'] = row[idx] else: d[col[0]] = row[idx] return d
python
{ "resource": "" }
q37912
Storage._create_table
train
def _create_table(self, table_name): ''' create sqlite's table for storing simple dictionaries ''' if self.fieldnames: sql_fields = [] for field in self._fields: if field != '_id': if 'dblite' in self._fields[field]: ...
python
{ "resource": "" }
q37913
Storage._make_item
train
def _make_item(self, item): ''' make Item class ''' for field in self._item_class.fields: if (field in item) and ('dblite_serializer' in self._item_class.fields[field]): serializer = self._item_class.fields[field]['dblite_serializer'] item[field] = ser...
python
{ "resource": "" }
q37914
Storage._get_all
train
def _get_all(self): ''' return all items ''' rowid = 0 while True: SQL_SELECT_MANY = 'SELECT rowid, * FROM %s WHERE rowid > ? LIMIT ?;' % self._table self._cursor.execute(SQL_SELECT_MANY, (rowid, ITEMS_PER_REQUEST)) items = self._cursor.fetchall() ...
python
{ "resource": "" }
q37915
Storage.get_one
train
def get_one(self, criteria): ''' return one item ''' try: items = [item for item in self._get_with_criteria(criteria, limit=1)] return items[0] except: return None
python
{ "resource": "" }
q37916
Storage.put
train
def put(self, item): ''' store item in sqlite database ''' if isinstance(item, self._item_class): self._put_one(item) elif isinstance(item, (list, tuple)): self._put_many(item) else: raise RuntimeError('Unknown item(s) type, %s' % type(item))
python
{ "resource": "" }
q37917
Storage._put_one
train
def _put_one(self, item): ''' store one item in database ''' # prepare values values = [] for k, v in item.items(): if k == '_id': continue if 'dblite_serializer' in item.fields[k]: serializer = item.fields[k]['dblite_serial...
python
{ "resource": "" }
q37918
Storage._put_many
train
def _put_many(self, items): ''' store items in sqlite database ''' for item in items: if not isinstance(item, self._item_class): raise RuntimeError('Items mismatch for %s and %s' % (self._item_class, type(item))) self._put_one(item)
python
{ "resource": "" }
q37919
Storage.sql
train
def sql(self, sql, params=()): ''' execute sql request and return items ''' def _items(items): for item in items: yield self._item_class(item) sql = sql.strip() try: self._cursor.execute(sql, params) except sqlite3.OperationalError...
python
{ "resource": "" }
q37920
run_tasks
train
def run_tasks(tasks, max_workers=None, use_processes=False): """ Run an iterable of tasks. tasks: The iterable of tasks max_workers: (optional, None) The maximum number of workers to use. As of Python 3.5, if None is passed to the thread executor will default to 5 * the number of proces...
python
{ "resource": "" }
q37921
wait_for_zone_op
train
def wait_for_zone_op(access_token, project, zone, name, interval=1.0): """Wait until a zone operation is finished. TODO: docstring""" assert isinstance(interval, (int, float)) assert interval >= 0.1 status = 'RUNNING' progress = 0 LOGGER.info('Waiting for zone operation "%s" to finis...
python
{ "resource": "" }
q37922
LocalAlignment._initialise
train
def _initialise(self): """ Initialises table with dictionary. """ d = {'score': 0, 'pointer': None, 'ins': 0, 'del': 0} cols = len(self.seq1Seq) + 1 rows = len(self.seq2Seq) + 1 # Note that this puts a ref to the same dict (d) into each cell of # the table...
python
{ "resource": "" }
q37923
LocalAlignment._cigarString
train
def _cigarString(self, output): """ Return a cigar string of aligned sequences. @param output: a C{tup} of strings (align1, align, align2) @return: a C{str} containing the cigar string. Eg with input: 'GGCCCGCA' and 'GG-CTGCA', return 2=1D1=1X3= """ cigar = [...
python
{ "resource": "" }
q37924
LocalAlignment._alignmentToStr
train
def _alignmentToStr(self, result): """ Make a textual representation of an alignment result. @param result: A C{dict}, as returned by C{self.createAlignment}. @return: A C{str} desription of a result. For every three lines the first and third contain the input sequences, pos...
python
{ "resource": "" }
q37925
LocalAlignment.createAlignment
train
def createAlignment(self, resultFormat=dict): """ Run the alignment algorithm. @param resultFormat: Either C{dict} or C{str}, giving the desired result format. @return: If C{resultFormat} is C{dict}, a C{dict} containing information about the match (or C{None}) i...
python
{ "resource": "" }
q37926
SQLBuilder.select
train
def select(self, fields=['rowid', '*'], offset=None, limit=None): ''' return SELECT SQL ''' # base SQL SQL = 'SELECT %s FROM %s' % (','.join(fields), self._table) # selectors if self._selectors: SQL = ' '.join([SQL, 'WHERE', self._selectors]).strip() ...
python
{ "resource": "" }
q37927
SQLBuilder.delete
train
def delete(self): ''' return DELETE SQL ''' SQL = 'DELETE FROM %s' % self._table if self._selectors: SQL = ' '.join([SQL, 'WHERE', self._selectors]).strip() return SQL
python
{ "resource": "" }
q37928
SQLBuilder._parse
train
def _parse(self, params): ''' parse parameters and return SQL ''' if not isinstance(params, dict): return None, None if len(params) == 0: return None, None selectors = list() modifiers = list() for k in params.keys(): ...
python
{ "resource": "" }
q37929
SQLBuilder._value_wrapper
train
def _value_wrapper(self, value): ''' wrapper for values ''' if isinstance(value, (int, float,)): return '=%s' % value elif isinstance(value, (str, unicode)): value = value.strip() # LIKE if RE_LIKE.match(value): return ' LI...
python
{ "resource": "" }
q37930
make_router
train
def make_router(*routings): """Return a WSGI application that dispatches requests to controllers """ routes = [] for routing in routings: methods, regex, app = routing[:3] if isinstance(methods, basestring): methods = (methods,) vars = routing[3] if len(routing) >= 4 else...
python
{ "resource": "" }
q37931
respond_json
train
def respond_json(ctx, data, code = None, headers = [], json_dumps_default = None, jsonp = None): """Return a JSON response. This function is optimized for JSON following `Google JSON Style Guide <http://google-styleguide.googlecode.com/svn/trunk/jsoncstyleguide.xml>`_, but will handle any JSON except f...
python
{ "resource": "" }
q37932
get_assembly
train
def get_assembly(name): """read a single assembly by name, returning a dictionary of assembly data >>> assy = get_assembly('GRCh37.p13') >>> assy['name'] 'GRCh37.p13' >>> assy['description'] 'Genome Reference Consortium Human Build 37 patch release 13 (GRCh37.p13)' >>> assy['refseq_ac'] ...
python
{ "resource": "" }
q37933
make_name_ac_map
train
def make_name_ac_map(assy_name, primary_only=False): """make map from sequence name to accession for given assembly name >>> grch38p5_name_ac_map = make_name_ac_map('GRCh38.p5') >>> grch38p5_name_ac_map['1'] 'NC_000001.11' """ return { s['name']: s['refseq_ac'] for s in get_ass...
python
{ "resource": "" }
q37934
main
train
def main(args=None): """Extract all exon annotations of protein-coding genes.""" if args is None: parser = get_argument_parser() args = parser.parse_args() input_file = args.annotation_file output_file = args.output_file species = args.species chrom_pat = args.chromosome_patter...
python
{ "resource": "" }
q37935
titleCounts
train
def titleCounts(readsAlignments): """ Count the number of times each title in a readsAlignments instance is matched. This is useful for rapidly discovering what titles were matched and with what frequency. @param readsAlignments: A L{dark.alignments.ReadsAlignments} instance. @return: A C{dict}...
python
{ "resource": "" }
q37936
TitleAlignment.toDict
train
def toDict(self): """ Get information about a title alignment as a dictionary. @return: A C{dict} representation of the title aligment. """ return { 'hsps': [hsp.toDict() for hsp in self.hsps], 'read': self.read.toDict(), }
python
{ "resource": "" }
q37937
TitleAlignments.hasScoreBetterThan
train
def hasScoreBetterThan(self, score): """ Is there an HSP with a score better than a given value? @return: A C{bool}, C{True} if there is at least one HSP in the alignments for this title with a score better than C{score}. """ # Note: Do not assume that HSPs in an alignme...
python
{ "resource": "" }
q37938
TitleAlignments.coverage
train
def coverage(self): """ Get the fraction of this title sequence that is matched by its reads. @return: The C{float} fraction of the title sequence matched by its reads. """ intervals = ReadIntervals(self.subjectLength) for hsp in self.hsps(): inte...
python
{ "resource": "" }
q37939
TitleAlignments.coverageInfo
train
def coverageInfo(self): """ Return information about the bases found at each location in our title sequence. @return: A C{dict} whose keys are C{int} subject offsets and whose values are unsorted lists of (score, base) 2-tuples, giving all the bases from reads th...
python
{ "resource": "" }
q37940
TitleAlignments.residueCounts
train
def residueCounts(self, convertCaseTo='upper'): """ Count residue frequencies at all sequence locations matched by reads. @param convertCaseTo: A C{str}, 'upper', 'lower', or 'none'. If 'none', case will not be converted (both the upper and lower case string of a residue...
python
{ "resource": "" }
q37941
TitleAlignments.summary
train
def summary(self): """ Summarize the alignments for this subject. @return: A C{dict} with C{str} keys: bestScore: The C{float} best score of the matching reads. coverage: The C{float} fraction of the subject genome that is matched by at least one read. ...
python
{ "resource": "" }
q37942
TitleAlignments.toDict
train
def toDict(self): """ Get information about the title's alignments as a dictionary. @return: A C{dict} representation of the title's aligments. """ return { 'titleAlignments': [titleAlignment.toDict() for titleAlignment in self], ...
python
{ "resource": "" }
q37943
TitlesAlignments.addTitle
train
def addTitle(self, title, titleAlignments): """ Add a new title to self. @param title: A C{str} title. @param titleAlignments: An instance of L{TitleAlignments}. @raises KeyError: If the title is already present. """ if title in self: raise KeyError('...
python
{ "resource": "" }
q37944
TitlesAlignments.filter
train
def filter(self, minMatchingReads=None, minMedianScore=None, withScoreBetterThan=None, minNewReads=None, minCoverage=None, maxTitles=None, sortOn='maxScore'): """ Filter the titles in self to create another TitlesAlignments. @param minMatchingReads: titles that are...
python
{ "resource": "" }
q37945
TitlesAlignments.hsps
train
def hsps(self): """ Get all HSPs for all the alignments for all titles. @return: A generator yielding L{dark.hsp.HSP} instances. """ return (hsp for titleAlignments in self.values() for alignment in titleAlignments for hsp in alignment.hsps)
python
{ "resource": "" }
q37946
TitlesAlignments.sortTitles
train
def sortTitles(self, by): """ Sort titles by a given attribute and then by title. @param by: A C{str}, one of 'length', 'maxScore', 'medianScore', 'readCount', or 'title'. @raise ValueError: If an unknown C{by} value is given. @return: A sorted C{list} of titles. ...
python
{ "resource": "" }
q37947
TitlesAlignments.summary
train
def summary(self, sortOn=None): """ Summarize all the alignments for this title. @param sortOn: A C{str} attribute to sort titles on. One of 'length', 'maxScore', 'medianScore', 'readCount', or 'title'. @raise ValueError: If an unknown C{sortOn} value is given. @retu...
python
{ "resource": "" }
q37948
TitlesAlignments.tabSeparatedSummary
train
def tabSeparatedSummary(self, sortOn=None): """ Summarize all the alignments for this title as multi-line string with TAB-separated values on each line. @param sortOn: A C{str} attribute to sort titles on. One of 'length', 'maxScore', 'medianScore', 'readCount', or 'title'. ...
python
{ "resource": "" }
q37949
TitlesAlignments.toDict
train
def toDict(self): """ Get information about the titles alignments as a dictionary. @return: A C{dict} representation of the titles aligments. """ return { 'scoreClass': self.scoreClass.__name__, 'titles': dict((title, titleAlignments.toDict()) ...
python
{ "resource": "" }
q37950
addFASTAFilteringCommandLineOptions
train
def addFASTAFilteringCommandLineOptions(parser): """ Add standard FASTA filtering command-line options to an argparse parser. These are options that can be used to select or omit entire FASTA records, NOT options that change them (for that see addFASTAEditingCommandLineOptions). @param parser:...
python
{ "resource": "" }
q37951
parseFASTAFilteringCommandLineOptions
train
def parseFASTAFilteringCommandLineOptions(args, reads): """ Examine parsed FASTA filtering command-line options and return filtered reads. @param args: An argparse namespace, as returned by the argparse C{parse_args} function. @param reads: A C{Reads} instance to filter. @return: The fi...
python
{ "resource": "" }
q37952
addFASTAEditingCommandLineOptions
train
def addFASTAEditingCommandLineOptions(parser): """ Add standard FASTA editing command-line options to an argparse parser. These are options that can be used to alter FASTA records, NOT options that simply select or reject those things (for those see addFASTAFilteringCommandLineOptions). @param...
python
{ "resource": "" }
q37953
parseFASTAEditingCommandLineOptions
train
def parseFASTAEditingCommandLineOptions(args, reads): """ Examine parsed FASTA editing command-line options and return information about kept sites and sequences. @param args: An argparse namespace, as returned by the argparse C{parse_args} function. @param reads: A C{Reads} instance to fil...
python
{ "resource": "" }
q37954
XMLRecordsReader.records
train
def records(self): """ Yield BLAST records, as read by the BioPython NCBIXML.parse method. Set self.params from data in the first record. """ first = True with as_handle(self._filename) as fp: for record in NCBIXML.parse(fp): if first: ...
python
{ "resource": "" }
q37955
XMLRecordsReader.saveAsJSON
train
def saveAsJSON(self, fp): """ Write the records out as JSON. The first JSON object saved contains the BLAST parameters. @param fp: A C{str} file pointer to write to. """ first = True for record in self.records(): if first: print(dumps(...
python
{ "resource": "" }
q37956
JSONRecordsReader._open
train
def _open(self, filename): """ Open the input file. Set self._fp to point to it. Read the first line of parameters. @param filename: A C{str} filename containing JSON BLAST records. @raise ValueError: if the first line of the file isn't valid JSON, if the input file ...
python
{ "resource": "" }
q37957
JSONRecordsReader.readAlignments
train
def readAlignments(self, reads): """ Read lines of JSON from self._filename, convert them to read alignments and yield them. @param reads: An iterable of L{Read} instances, corresponding to the reads that were given to BLAST. @raise ValueError: If any of the lines in...
python
{ "resource": "" }
q37958
_makeComplementTable
train
def _makeComplementTable(complementData): """ Make a sequence complement table. @param complementData: A C{dict} whose keys and values are strings of length one. A key, value pair indicates a substitution that should be performed during complementation. @return: A 256 character string t...
python
{ "resource": "" }
q37959
addFASTACommandLineOptions
train
def addFASTACommandLineOptions(parser): """ Add standard command-line options to an argparse parser. @param parser: An C{argparse.ArgumentParser} instance. """ parser.add_argument( '--fastaFile', type=open, default=sys.stdin, metavar='FILENAME', help=('The name of the FASTA input f...
python
{ "resource": "" }
q37960
parseFASTACommandLineOptions
train
def parseFASTACommandLineOptions(args): """ Examine parsed command-line options and return a Reads instance. @param args: An argparse namespace, as returned by the argparse C{parse_args} function. @return: A C{Reads} subclass instance, depending on the type of FASTA file given. """ ...
python
{ "resource": "" }
q37961
_NucleotideRead.translations
train
def translations(self): """ Yield all six translations of a nucleotide sequence. @return: A generator that produces six L{TranslatedRead} instances. """ rc = self.reverseComplement().sequence for reverseComplemented in False, True: for frame in 0, 1, 2: ...
python
{ "resource": "" }
q37962
_NucleotideRead.reverseComplement
train
def reverseComplement(self): """ Reverse complement a nucleotide sequence. @return: The reverse complemented sequence as an instance of the current class. """ quality = None if self.quality is None else self.quality[::-1] sequence = self.sequence.translate(se...
python
{ "resource": "" }
q37963
AARead.checkAlphabet
train
def checkAlphabet(self, count=10): """ A function which checks if an AA read really contains amino acids. This additional testing is needed, because the letters in the DNA alphabet are also in the AA alphabet. @param count: An C{int}, indicating how many bases or amino acids at ...
python
{ "resource": "" }
q37964
AARead.ORFs
train
def ORFs(self, openORFs=False): """ Find all ORFs in our sequence. @param openORFs: If C{True} allow ORFs that do not have a start codon and/or do not have a stop codon. @return: A generator that yields AAReadORF instances that correspond to the ORFs found in the...
python
{ "resource": "" }
q37965
SSAARead.newFromSites
train
def newFromSites(self, sites, exclude=False): """ Create a new read from self, with only certain sites. @param sites: A set of C{int} 0-based sites (i.e., indices) in sequences that should be kept. If C{None} (the default), all sites are kept. @param exclude: If ...
python
{ "resource": "" }
q37966
Reads.filterRead
train
def filterRead(self, read): """ Filter a read, according to our set of filters. @param read: A C{Read} instance or one of its subclasses. @return: C{False} if the read fails any of our filters, else the C{Read} instance returned by our list of filters. """ fo...
python
{ "resource": "" }
q37967
Reads.summarizePosition
train
def summarizePosition(self, index): """ Compute residue counts at a specific sequence index. @param index: an C{int} index into the sequence. @return: A C{dict} with the count of too-short (excluded) sequences, and a Counter instance giving the residue counts. """ ...
python
{ "resource": "" }
q37968
condition2checker
train
def condition2checker(condition): """Converts different condition types to callback""" if isinstance(condition, string_types): def smatcher(info): return fnmatch.fnmatch(info.filename, condition) return smatcher elif isinstance(condition, (list, tuple)) and isinstance(condition[...
python
{ "resource": "" }
q37969
GeneSetEnrichmentAnalysis.get_static_enrichment
train
def get_static_enrichment( self, genes: Iterable[str], pval_thresh: float, adjust_pval_thresh: bool = True, K_min: int = 3, gene_set_ids: Iterable[str] = None) -> StaticGSEResult: """Find enriched gene sets in a set of genes. Parameters ...
python
{ "resource": "" }
q37970
get_connection_string
train
def get_connection_string(connection=None): """return SQLAlchemy connection string if it is set :param connection: get the SQLAlchemy connection string #TODO :rtype: str """ if not connection: config = configparser.ConfigParser() cfp = defaults.config_file_path if os.path.ex...
python
{ "resource": "" }
q37971
export_obo
train
def export_obo(path_to_file, connection=None): """export database to obo file :param path_to_file: path to export file :param connection: connection string (optional) :return: """ db = DbManager(connection) db.export_obo(path_to_export_file=path_to_file) db.session.close()
python
{ "resource": "" }
q37972
DbManager.db_import_xml
train
def db_import_xml(self, url=None, force_download=False, taxids=None, silent=False): """Updates the CTD database 1. downloads gzipped XML 2. drops all tables in database 3. creates all tables in database 4. import XML 5. close session :param Optional[list...
python
{ "resource": "" }
q37973
DbManager.insert_entries
train
def insert_entries(self, entries_xml, taxids=None): """Inserts UniProt entries from XML :param str entries_xml: XML string :param Optional[list[int]] taxids: NCBI taxonomy IDs """ entries = etree.fromstring(entries_xml) del entries_xml for entry in entries: ...
python
{ "resource": "" }
q37974
DbManager.insert_entry
train
def insert_entry(self, entry, taxids): """Insert UniProt entry" :param entry: XML node entry :param taxids: Optional[iter[int]] taxids: NCBI taxonomy IDs """ entry_dict = entry.attrib entry_dict['created'] = datetime.strptime(entry_dict['created'], '%Y-%m-%d') en...
python
{ "resource": "" }
q37975
DbManager.get_sequence
train
def get_sequence(cls, entry): """ get models.Sequence object from XML node entry :param entry: XML node entry :return: :class:`pyuniprot.manager.models.Sequence` object """ seq_tag = entry.find("./sequence") seq = seq_tag.text seq_tag.clear() retu...
python
{ "resource": "" }
q37976
DbManager.get_tissue_in_references
train
def get_tissue_in_references(self, entry): """ get list of models.TissueInReference from XML node entry :param entry: XML node entry :return: list of :class:`pyuniprot.manager.models.TissueInReference` objects """ tissue_in_references = [] query = "./reference/so...
python
{ "resource": "" }
q37977
DbManager.get_subcellular_locations
train
def get_subcellular_locations(self, entry): """ get list of models.SubcellularLocation object from XML node entry :param entry: XML node entry :return: list of :class:`pyuniprot.manager.models.SubcellularLocation` object """ subcellular_locations = [] query = './...
python
{ "resource": "" }
q37978
DbManager.get_keywords
train
def get_keywords(self, entry): """ get list of models.Keyword objects from XML node entry :param entry: XML node entry :return: list of :class:`pyuniprot.manager.models.Keyword` objects """ keyword_objects = [] for keyword in entry.iterfind("./keyword"): ...
python
{ "resource": "" }
q37979
DbManager.get_disease_comments
train
def get_disease_comments(self, entry): """ get list of models.Disease objects from XML node entry :param entry: XML node entry :return: list of :class:`pyuniprot.manager.models.Disease` objects """ disease_comments = [] query = "./comment[@type='disease']" ...
python
{ "resource": "" }
q37980
DbManager.get_alternative_full_names
train
def get_alternative_full_names(cls, entry): """ get list of models.AlternativeFullName objects from XML node entry :param entry: XML node entry :return: list of :class:`pyuniprot.manager.models.AlternativeFullName` objects """ names = [] query = "./protein/altern...
python
{ "resource": "" }
q37981
DbManager.get_alternative_short_names
train
def get_alternative_short_names(cls, entry): """ get list of models.AlternativeShortName objects from XML node entry :param entry: XML node entry :return: list of :class:`pyuniprot.manager.models.AlternativeShortName` objects """ names = [] query = "./protein/alt...
python
{ "resource": "" }
q37982
DbManager.get_ec_numbers
train
def get_ec_numbers(cls, entry): """ get list of models.ECNumber objects from XML node entry :param entry: XML node entry :return: list of models.ECNumber objects """ ec_numbers = [] for ec in entry.iterfind("./protein/recommendedName/ecNumber"): ec_...
python
{ "resource": "" }
q37983
DbManager.get_gene_name
train
def get_gene_name(cls, entry): """ get primary gene name from XML node entry :param entry: XML node entry :return: str """ gene_name = entry.find("./gene/name[@type='primary']") return gene_name.text if gene_name is not None and gene_name.text.strip() else None
python
{ "resource": "" }
q37984
DbManager.get_other_gene_names
train
def get_other_gene_names(cls, entry): """ get list of `models.OtherGeneName` objects from XML node entry :param entry: XML node entry :return: list of :class:`pyuniprot.manager.models.models.OtherGeneName` objects """ alternative_gene_names = [] for alternative_...
python
{ "resource": "" }
q37985
DbManager.get_accessions
train
def get_accessions(cls, entry): """ get list of models.Accession from XML node entry :param entry: XML node entry :return: list of :class:`pyuniprot.manager.models.Accession` objects """ return [models.Accession(accession=x.text) for x in entry.iterfind("./accession")]
python
{ "resource": "" }
q37986
DbManager.get_db_references
train
def get_db_references(cls, entry): """ get list of `models.DbReference` from XML node entry :param entry: XML node entry :return: list of :class:`pyuniprot.manager.models.DbReference` """ db_refs = [] for db_ref in entry.iterfind("./dbReference"): d...
python
{ "resource": "" }
q37987
DbManager.get_features
train
def get_features(cls, entry): """ get list of `models.Feature` from XML node entry :param entry: XML node entry :return: list of :class:`pyuniprot.manager.models.Feature` """ features = [] for feature in entry.iterfind("./feature"): feature_dict = {...
python
{ "resource": "" }
q37988
DbManager.get_recommended_protein_name
train
def get_recommended_protein_name(cls, entry): """ get recommended full and short protein name as tuple from XML node :param entry: XML node entry :return: (str, str) => (full, short) """ query_full = "./protein/recommendedName/fullName" full_name = entry.find(que...
python
{ "resource": "" }
q37989
DbManager.get_organism_hosts
train
def get_organism_hosts(cls, entry): """ get list of `models.OrganismHost` objects from XML node entry :param entry: XML node entry :return: list of :class:`pyuniprot.manager.models.OrganismHost` objects """ query = "./organismHost/dbReference[@type='NCBI Taxonomy']" ...
python
{ "resource": "" }
q37990
DbManager.get_pmids
train
def get_pmids(self, entry): """ get `models.Pmid` objects from XML node entry :param entry: XML node entry :return: list of :class:`pyuniprot.manager.models.Pmid` objects """ pmids = [] for citation in entry.iterfind("./reference/citation"): for pub...
python
{ "resource": "" }
q37991
DbManager.get_functions
train
def get_functions(cls, entry): """ get `models.Function` objects from XML node entry :param entry: XML node entry :return: list of :class:`pyuniprot.manager.models.Function` objects """ comments = [] query = "./comment[@type='function']" for comment in en...
python
{ "resource": "" }
q37992
Graph.resolve_nodes
train
def resolve_nodes(self, nodes): """ Resolve a given set of nodes. Dependencies of the nodes, even if they are not in the given list will also be resolved! :param list nodes: List of nodes to be resolved :return: A list of resolved nodes """ if not nodes:...
python
{ "resource": "" }
q37993
Graph.resolve_node
train
def resolve_node(self, node=None, resolved=None, seen=None): """ Resolve a single node or all when node is omitted. """ if seen is None: seen = [] if resolved is None: resolved = [] if node is None: dependencies = sorted(self._nodes.key...
python
{ "resource": "" }
q37994
findCodons
train
def findCodons(seq, codons): """ Find all instances of the codons in 'codons' in the given sequence. seq: A Bio.Seq.Seq instance. codons: A set of codon strings. Return: a generator yielding matching codon offsets. """ seqLen = len(seq) start = 0 while start < seqLen: tripl...
python
{ "resource": "" }
q37995
needle
train
def needle(reads): """ Run a Needleman-Wunsch alignment and return the two sequences. @param reads: An iterable of two reads. @return: A C{Reads} instance with the two aligned sequences. """ from tempfile import mkdtemp from shutil import rmtree dir = mkdtemp() file1 = join(dir, '...
python
{ "resource": "" }
q37996
read_until
train
def read_until(stream, delimiter, max_bytes=16): """Read until we have found the given delimiter. :param file stream: readable file-like object. :param bytes delimiter: delimiter string. :param int max_bytes: maximum bytes to read. :rtype: bytes|None """ buf = bytearray() delim_len = ...
python
{ "resource": "" }
q37997
dechunk
train
def dechunk(stream): """De-chunk HTTP body stream. :param file stream: readable file-like object. :rtype: __generator[bytes] :raise: DechunkError """ # TODO(vovan): Add support for chunk extensions: # TODO(vovan): http://tools.ietf.org/html/rfc2616#section-3.6.1 while True: c...
python
{ "resource": "" }
q37998
to_chunks
train
def to_chunks(stream_or_generator): """This generator function receives file-like or generator as input and returns generator. :param file|__generator[bytes] stream_or_generator: readable stream or generator. :rtype: __generator[bytes] :raise: TypeError """ if isinstance(strea...
python
{ "resource": "" }
q37999
read_body_stream
train
def read_body_stream(stream, chunked=False, compression=None): """Read HTTP body stream, yielding blocks of bytes. De-chunk and de-compress data if needed. :param file stream: readable stream. :param bool chunked: whether stream is chunked. :param str|None compression: compression type is stream is...
python
{ "resource": "" }