Code
stringlengths
103
85.9k
Summary
listlengths
0
94
Please provide a description of the function:def join_json_files(prefix): try: with open(prefix + '.uaz.entities.json', 'rt') as f: entities = json.load(f) with open(prefix + '.uaz.events.json', 'rt') as f: events = json.load(f) with open(prefix + '.uaz.sentences...
[ "Join different REACH output JSON files into a single JSON object.\n\n The output of REACH is broken into three files that need to be joined\n before processing. Specifically, there will be three files of the form:\n `<prefix>.uaz.<subcategory>.json`.\n\n Parameters\n ----------\n prefix : str\n ...
Please provide a description of the function:def read_pmid(pmid, source, cont_path, sparser_version, outbuf=None, cleanup=True): "Run sparser on a single pmid." signal.signal(signal.SIGALRM, _timeout_handler) signal.alarm(60) try: if (source is 'content_not_found' or sou...
[]
Please provide a description of the function:def get_stmts(pmids_unread, cleanup=True, sparser_version=None): "Run sparser on the pmids in pmids_unread." if sparser_version is None: sparser_version = sparser.get_version() stmts = {} now = datetime.now() outbuf_fname = 'sparser_%s_%s.log' % (...
[]
Please provide a description of the function:def run_sparser(pmid_list, tmp_dir, num_cores, start_index, end_index, force_read, force_fulltext, cleanup=True, verbose=True): 'Run the sparser reader on the pmids in pmid_list.' reader_version = sparser.get_version() _, _, _, pmids_read, pmids_u...
[]
Please provide a description of the function:def upload_process_reach_files(output_dir, pmid_info_dict, reader_version, num_cores): # At this point, we have a directory full of JSON files # Collect all the prefixes into a set, then iterate over the prefixes # Collect prefixes...
[ "\n logger.info('Uploaded REACH JSON for %d files to S3 (%d failures)' %\n (num_uploaded, num_failures))\n failures_file = os.path.join(output_dir, 'failures.txt')\n with open(failures_file, 'wt') as f:\n for fail in failures:\n f.write('%s\\n' % fail)\n " ]
Please provide a description of the function:def run_reach(pmid_list, base_dir, num_cores, start_index, end_index, force_read, force_fulltext, cleanup=False, verbose=True): logger.info('Running REACH with force_read=%s' % force_read) logger.info('Running REACH with force_fulltext=%s' % force_...
[ "Run reach on a list of pmids." ]
Please provide a description of the function:def get_all_descendants(parent): children = parent.__subclasses__() descendants = children[:] for child in children: descendants += get_all_descendants(child) return descendants
[ "Get all the descendants of a parent class, recursively." ]
Please provide a description of the function:def get_type_hierarchy(s): tp = type(s) if not isinstance(s, type) else s p_list = [tp] for p in tp.__bases__: if p is not Statement: p_list.extend(get_type_hierarchy(p)) else: p_list.append(p) return p_list
[ "Get the sequence of parents from `s` to Statement.\n\n Parameters\n ----------\n s : a class or instance of a child of Statement\n For example the statement `Phosphorylation(MEK(), ERK())` or just the\n class `Phosphorylation`.\n\n Returns\n -------\n parent_list : list[types]\n ...
Please provide a description of the function:def get_statement_by_name(stmt_name): stmt_classes = get_all_descendants(Statement) for stmt_class in stmt_classes: if stmt_class.__name__.lower() == stmt_name.lower(): return stmt_class raise NotAStatementName('\"%s\" is not recognized a...
[ "Get a statement class given the name of the statement class." ]
Please provide a description of the function:def get_unresolved_support_uuids(stmts): return {s.uuid for stmt in stmts for s in stmt.supports + stmt.supported_by if isinstance(s, Unresolved)}
[ "Get uuids unresolved in support from stmts from stmts_from_json." ]
Please provide a description of the function:def stmt_type(obj, mk=True): if isinstance(obj, Statement) and mk: return type(obj) else: return type(obj).__name__
[ "Return standardized, backwards compatible object type String.\n\n This is a temporary solution to make sure type comparisons and\n matches keys of Statements and related classes are backwards\n compatible.\n " ]
Please provide a description of the function:def get_hash(self, shallow=True, refresh=False): if shallow: if not hasattr(self, '_shallow_hash') or self._shallow_hash is None\ or refresh: self._shallow_hash = make_hash(self.matches_key(), 14) r...
[ "Get a hash for this Statement.\n\n There are two types of hash, \"shallow\" and \"full\". A shallow hash is\n as unique as the information carried by the statement, i.e. it is a hash\n of the `matches_key`. This means that differences in source, evidence,\n and so on are not included. A...
Please provide a description of the function:def _tag_evidence(self): h = self.get_hash(shallow=False) for ev in self.evidence: ev.stmt_tag = h return
[ "Set all the Evidence stmt_tag to my deep matches-key hash." ]
Please provide a description of the function:def agent_list(self, deep_sorted=False): ag_list = [] for ag_name in self._agent_order: ag_attr = getattr(self, ag_name) if isinstance(ag_attr, Concept) or ag_attr is None: ag_list.append(ag_attr) e...
[ "Get the canonicallized agent list." ]
Please provide a description of the function:def to_json(self, use_sbo=False): stmt_type = type(self).__name__ # Original comment: For backwards compatibility, could be removed later all_stmts = [self] + self.supports + self.supported_by for st in all_stmts: if not h...
[ "Return serialized Statement as a JSON dict.\n\n Parameters\n ----------\n use_sbo : Optional[bool]\n If True, SBO annotations are added to each applicable element of\n the JSON. Default: False\n\n Returns\n -------\n json_dict : dict\n The ...
Please provide a description of the function:def to_graph(self): def json_node(graph, element, prefix): if not element: return None node_id = '|'.join(prefix) if isinstance(element, list): graph.add_node(node_id, label='') ...
[ "Return Statement as a networkx graph." ]
Please provide a description of the function:def make_generic_copy(self, deeply=False): if deeply: kwargs = deepcopy(self.__dict__) else: kwargs = self.__dict__.copy() for attr in ['evidence', 'belief', 'uuid', 'supports', 'supported_by', 'is...
[ "Make a new matching Statement with no provenance.\n\n All agents and other attributes besides evidence, belief, supports, and\n supported_by will be copied over, and a new uuid will be assigned.\n Thus, the new Statement will satisfy `new_stmt.matches(old_stmt)`.\n\n If `deeply` is set ...
Please provide a description of the function:def load_lincs_csv(url): resp = requests.get(url, params={'output_type': '.csv'}, timeout=120) resp.raise_for_status() if sys.version_info[0] < 3: csv_io = BytesIO(resp.content) else: csv_io = StringIO(resp.text) data_rows = list(read...
[ "Helper function to turn csv rows into dicts." ]
Please provide a description of the function:def get_small_molecule_name(self, hms_lincs_id): entry = self._get_entry_by_id(self._sm_data, hms_lincs_id) if not entry: return None name = entry['Name'] return name
[ "Get the name of a small molecule from the LINCS sm metadata.\n\n Parameters\n ----------\n hms_lincs_id : str\n The HMS LINCS ID of the small molecule.\n\n Returns\n -------\n str\n The name of the small molecule.\n " ]
Please provide a description of the function:def get_small_molecule_refs(self, hms_lincs_id): refs = {'HMS-LINCS': hms_lincs_id} entry = self._get_entry_by_id(self._sm_data, hms_lincs_id) # If there is no entry for this ID if not entry: return refs # If the...
[ "Get the id refs of a small molecule from the LINCS sm metadata.\n\n Parameters\n ----------\n hms_lincs_id : str\n The HMS LINCS ID of the small molecule.\n\n Returns\n -------\n dict\n A dictionary of references.\n " ]
Please provide a description of the function:def get_protein_refs(self, hms_lincs_id): # TODO: We could get phosphorylation states from the protein data. refs = {'HMS-LINCS': hms_lincs_id} entry = self._get_entry_by_id(self._prot_data, hms_lincs_id) # If there is no entry for t...
[ "Get the refs for a protein from the LINCs protein metadata.\n\n Parameters\n ----------\n hms_lincs_id : str\n The HMS LINCS ID for the protein\n\n Returns\n -------\n dict\n A dictionary of protein references.\n " ]
Please provide a description of the function:def get_bel_stmts(self, filter=False): if self.basename is not None: bel_stmt_path = '%s_bel_stmts.pkl' % self.basename # Check for cached BEL stmt file if self.basename is not None and os.path.isfile(bel_stmt_path): l...
[ "Get relevant statements from the BEL large corpus.\n\n Performs a series of neighborhood queries and then takes the union of\n all the statements. Because the query process can take a long time for\n large gene lists, the resulting list of statements are cached in a\n pickle file with t...
Please provide a description of the function:def get_biopax_stmts(self, filter=False, query='pathsbetween', database_filter=None): # If we're using a cache, initialize the appropriate filenames if self.basename is not None: biopax_stmt_path = '%s_biopax_stmt...
[ "Get relevant statements from Pathway Commons.\n\n Performs a \"paths between\" query for the genes in :py:attr:`gene_list`\n and uses the results to build statements. This function caches two\n files: the list of statements built from the query, which is cached in\n `<basename>_biopax_s...
Please provide a description of the function:def get_statements(self, filter=False): bp_stmts = self.get_biopax_stmts(filter=filter) bel_stmts = self.get_bel_stmts(filter=filter) return bp_stmts + bel_stmts
[ "Return the combined list of statements from BEL and Pathway Commons.\n\n Internally calls :py:meth:`get_biopax_stmts` and\n :py:meth:`get_bel_stmts`.\n\n Parameters\n ----------\n filter : bool\n If True, includes only those statements that exclusively mention\n ...
Please provide a description of the function:def run_preassembly(self, stmts, print_summary=True): # First round of preassembly: remove duplicates before sitemapping pa1 = Preassembler(hierarchies, stmts) logger.info("Combining duplicates") pa1.combine_duplicates() # Map...
[ "Run complete preassembly procedure on the given statements.\n\n Results are returned as a dict and stored in the attribute\n :py:attr:`results`. They are also saved in the pickle file\n `<basename>_results.pkl`.\n\n Parameters\n ----------\n stmts : list of :py:class:`indr...
Please provide a description of the function:def _get_grounding(entity): db_refs = {'TEXT': entity['text']} groundings = entity.get('grounding') if not groundings: return db_refs def get_ont_concept(concept): # In the WM context, groundings have no URL prefix and start wit...
[ "Return Hume grounding.", "Strip slash, replace spaces and remove example leafs." ]
Please provide a description of the function:def _find_relations(self): # Get all extractions extractions = \ list(self.tree.execute("$.extractions[(@.@type is 'Extraction')]")) # Get relations from extractions relations = [] for e in extractions: ...
[ "Find all relevant relation elements and return them in a list." ]
Please provide a description of the function:def _get_documents(self): documents = self.tree.execute("$.documents") for doc in documents: sentences = {s['@id']: s['text'] for s in doc.get('sentences', [])} self.document_dict[doc['@id']] = {'sentences': sentences, ...
[ "Populate sentences attribute with a dict keyed by document id." ]
Please provide a description of the function:def _make_context(self, entity): loc_context = None time_context = None # Look for time and place contexts. for argument in entity["arguments"]: if argument["type"] == "place": entity_id = argument["value"...
[ "Get place and time info from the json for this entity." ]
Please provide a description of the function:def _make_concept(self, entity): # Use the canonical name as the name of the Concept by default name = self._sanitize(entity['canonicalName']) # But if there is a trigger head text, we prefer that since # it almost always results in a...
[ "Return Concept from a Hume entity.", "\n trigger = entity.get('trigger')\n if trigger is not None:\n head_text = trigger.get('head text')\n if head_text is not None:\n name = head_text\n " ]
Please provide a description of the function:def _get_event_and_context(self, event, arg_type): eid = _choose_id(event, arg_type) ev = self.concept_dict[eid] concept, metadata = self._make_concept(ev) ev_delta = {'adjectives': [], 'states': get_states(ev), ...
[ "Return an INDRA Event based on an event entry." ]
Please provide a description of the function:def _get_evidence(self, event, adjectives): provenance = event.get('provenance') # First try looking up the full sentence through provenance doc_id = provenance[0]['document']['@id'] sent_id = provenance[0]['sentence'] text =...
[ "Return the Evidence object for the INDRA Statement." ]
Please provide a description of the function:def _is_statement_in_list(new_stmt, old_stmt_list): for old_stmt in old_stmt_list: if old_stmt.equals(new_stmt): return True elif old_stmt.evidence_equals(new_stmt) and old_stmt.matches(new_stmt): # If we're comparing a comple...
[ "Return True of given statement is equivalent to on in a list\n\n Determines whether the statement is equivalent to any statement in the\n given list of statements, with equivalency determined by Statement's\n equals method.\n\n Parameters\n ----------\n new_stmt : indra.statements.Statement\n ...
Please provide a description of the function:def normalize_medscan_name(name): suffix = ' complex' for i in range(2): if name.endswith(suffix): name = name[:-len(suffix)] return name
[ "Removes the \"complex\" and \"complex complex\" suffixes from a medscan\n agent name so that it better corresponds with the grounding map.\n\n Parameters\n ----------\n name: str\n The Medscan agent name\n\n Returns\n -------\n norm_name: str\n The Medscan agent name with the \"c...
Please provide a description of the function:def _urn_to_db_refs(urn): # Convert a urn to a db_refs dictionary if urn is None: return {}, None m = URN_PATT.match(urn) if m is None: return None, None urn_type, urn_id = m.groups() db_refs = {} db_name = None # TODO...
[ "Converts a Medscan URN to an INDRA db_refs dictionary with grounding\n information.\n\n Parameters\n ----------\n urn : str\n A Medscan URN\n\n Returns\n -------\n db_refs : dict\n A dictionary with grounding information, mapping databases to database\n identifiers. If the...
Please provide a description of the function:def _untag_sentence(tagged_sentence): untagged_sentence = TAG_PATT.sub('\\2', tagged_sentence) clean_sentence = JUNK_PATT.sub('', untagged_sentence) return clean_sentence.strip()
[ "Removes all tags in the sentence, returning the original sentence\n without Medscan annotations.\n\n Parameters\n ----------\n tagged_sentence : str\n The tagged sentence\n\n Returns\n -------\n untagged_sentence : str\n Sentence with tags and annotations stripped out\n " ]
Please provide a description of the function:def _extract_sentence_tags(tagged_sentence): untagged_sentence = _untag_sentence(tagged_sentence) decluttered_sentence = JUNK_PATT.sub('', tagged_sentence) tags = {} # Iteratively look for all matches of this pattern endpos = 0 while True: ...
[ "Given a tagged sentence, extracts a dictionary mapping tags to the words\n or phrases that they tag.\n\n Parameters\n ----------\n tagged_sentence : str\n The sentence with Medscan annotations and tags\n\n Returns\n -------\n tags : dict\n A dictionary mapping tags to the words o...
Please provide a description of the function:def get_sites(self): st = self.site_text suffixes = [' residue', ' residues', ',', '/'] for suffix in suffixes: if st.endswith(suffix): st = st[:-len(suffix)] assert(not st.endswith(',')) # Strip p...
[ "Parse the site-text string and return a list of sites.\n\n Returns\n -------\n sites : list[Site]\n A list of position-residue pairs corresponding to the site-text\n " ]
Please provide a description of the function:def process_csxml_file(self, filename, interval=None, lazy=False): if interval is None: interval = (None, None) tmp_fname = tempfile.mktemp(os.path.basename(filename)) fix_character_encoding(filename, tmp_fname) self.__f...
[ "Processes a filehandle to MedScan csxml input into INDRA\n statements.\n\n The CSXML format consists of a top-level `<batch>` root element\n containing a series of `<doc>` (document) elements, in turn containing\n `<sec>` (section) elements, and in turn containing `<sent>` (sentence)\n ...
Please provide a description of the function:def process_relation(self, relation, last_relation): subj_res = self.agent_from_entity(relation, relation.subj) obj_res = self.agent_from_entity(relation, relation.obj) if subj_res is None or obj_res is None: # Don't extract a sta...
[ "Process a relation into an INDRA statement.\n\n Parameters\n ----------\n relation : MedscanRelation\n The relation to process (a CONTROL svo with normalized verb)\n last_relation : MedscanRelation\n The relation immediately proceding the relation to process within...
Please provide a description of the function:def agent_from_entity(self, relation, entity_id): # Extract sentence tags mapping ids to the text. We refer to this # mapping only if the entity doesn't appear in the grounded entity # list tags = _extract_sentence_tags(relation.tagge...
[ "Create a (potentially grounded) INDRA Agent object from a given\n Medscan entity describing the subject or object.\n\n Uses helper functions to convert a Medscan URN to an INDRA db_refs\n grounding dictionary.\n\n If the entity has properties indicating that it is a protein with\n ...
Please provide a description of the function:def get_parser(description, input_desc): parser = ArgumentParser(description=description) parser.add_argument( dest='input_file', help=input_desc ) parser.add_argument( '-r', '--readers', choices=['reach', 'sparser', '...
[ "Get a parser that is generic to reading scripts.\n\n Parameters\n ----------\n description : str\n A description of the tool, usually about one line long.\n input_desc: str\n A string describing the nature of the input file used by the reading\n tool.\n\n Returns\n -------\n ...
Please provide a description of the function:def send_request(endpoint, **kwargs): if api_key is None: logger.error('NewsAPI cannot be used without an API key') return None url = '%s/%s' % (newsapi_url, endpoint) if 'apiKey' not in kwargs: kwargs['apiKey'] = api_key if 'page...
[ "Return the response to a query as JSON from the NewsAPI web service.\n\n The basic API is limited to 100 results which is chosen unless explicitly\n given as an argument. Beyond that, paging is supported through the \"page\"\n argument, if needed.\n\n Parameters\n ----------\n endpoint : str\n ...
Please provide a description of the function:def process_cx_file(file_name, require_grounding=True): with open(file_name, 'rt') as fh: json_list = json.load(fh) return process_cx(json_list, require_grounding=require_grounding)
[ "Process a CX JSON file into Statements.\n\n Parameters\n ----------\n file_name : str\n Path to file containing CX JSON.\n require_grounding: bool\n Whether network nodes lacking grounding information should be included\n among the extracted Statements (default is True).\n\n Ret...
Please provide a description of the function:def process_ndex_network(network_id, username=None, password=None, require_grounding=True): nd = ndex2.client.Ndex2(username=username, password=password) res = nd.get_network_as_cx_stream(network_id) if res.status_code != 200: ...
[ "Process an NDEx network into Statements.\n\n Parameters\n ----------\n network_id : str\n NDEx network ID.\n username : str\n NDEx username.\n password : str\n NDEx password.\n require_grounding: bool\n Whether network nodes lacking grounding information should be incl...
Please provide a description of the function:def process_cx(cx_json, summary=None, require_grounding=True): ncp = NdexCxProcessor(cx_json, summary=summary, require_grounding=require_grounding) ncp.get_statements() return ncp
[ "Process a CX JSON object into Statements.\n\n Parameters\n ----------\n cx_json : list\n CX JSON object.\n summary : Optional[dict]\n The network summary object which can be obtained via\n get_network_summary through the web service. THis contains metadata\n such as the owne...
Please provide a description of the function:def read_files(files, readers, **kwargs): reading_content = [Content.from_file(filepath) for filepath in files] output_list = [] for reader in readers: res_list = reader.read(reading_content, **kwargs) if res_list is None: logger....
[ "Read the files in `files` with the reader objects in `readers`.\n\n Parameters\n ----------\n files : list [str]\n A list of file paths to be read by the readers. Supported files are\n limited to text and nxml files.\n readers : list [Reader instances]\n A list of Reader objects to...
Please provide a description of the function:def expand_families(self, stmts): new_stmts = [] for stmt in stmts: # Put together the lists of families, with their members. E.g., # for a statement involving RAF and MEK, should return a list of # tuples like [(B...
[ "Generate statements by expanding members of families and complexes.\n " ]
Please provide a description of the function:def update_ontology(ont_url, rdf_path): yaml_root = load_yaml_from_url(ont_url) G = rdf_graph_from_yaml(yaml_root) save_hierarchy(G, rdf_path)
[ "Load an ontology formatted like Eidos' from github." ]
Please provide a description of the function:def rdf_graph_from_yaml(yaml_root): G = Graph() for top_entry in yaml_root: assert len(top_entry) == 1 node = list(top_entry.keys())[0] build_relations(G, node, top_entry[node], None) return G
[ "Convert the YAML object into an RDF Graph object." ]
Please provide a description of the function:def load_yaml_from_url(ont_url): res = requests.get(ont_url) if res.status_code != 200: raise Exception('Could not load ontology from %s' % ont_url) root = yaml.load(res.content) return root
[ "Return a YAML object loaded from a YAML file URL." ]
Please provide a description of the function:def register_preprocessed_file(self, infile, pmid, extra_annotations): infile_base = os.path.basename(infile) outfile = os.path.join(self.preprocessed_dir, infile_base) shutil.copyfile(infile, outfile) infile_key = os.path.splitext(i...
[ "Set up already preprocessed text file for reading with ISI reader.\n\n This is essentially a mock function to \"register\" already preprocessed\n files and get an IsiPreprocessor object that can be passed to\n the IsiProcessor.\n\n Parameters\n ----------\n infile : str\n ...
Please provide a description of the function:def preprocess_plain_text_string(self, text, pmid, extra_annotations): output_file = '%s.txt' % self.next_file_id output_file = os.path.join(self.preprocessed_dir, output_file) # Tokenize sentence sentences = nltk.sent_tokenize(text)...
[ "Preprocess plain text string for use by ISI reader.\n\n Preprocessing is done by tokenizing into sentences and writing\n each sentence on its own line in a plain text file. All other\n preprocessing functions ultimately call this one.\n\n Parameters\n ----------\n text : s...
Please provide a description of the function:def preprocess_plain_text_file(self, filename, pmid, extra_annotations): with codecs.open(filename, 'r', encoding='utf-8') as f: content = f.read() self.preprocess_plain_text_string(content, pmid, ...
[ "Preprocess a plain text file for use with ISI reder.\n\n Preprocessing results in a new text file with one sentence\n per line.\n\n Parameters\n ----------\n filename : str\n The name of the plain text file\n pmid : str\n The PMID from which it comes,...
Please provide a description of the function:def preprocess_nxml_file(self, filename, pmid, extra_annotations): # Create a temporary directory tmp_dir = tempfile.mkdtemp('indra_isi_nxml2txt_output') # Run nxml2txt if nxml2txt_path is None: logger.error('NXML2TXT_PAT...
[ "Preprocess an NXML file for use with the ISI reader.\n\n Preprocessing is done by extracting plain text from NXML and then\n creating a text file with one sentence per line.\n\n Parameters\n ----------\n filename : str\n Filename of an nxml file to process\n pmi...
Please provide a description of the function:def preprocess_abstract_list(self, abstract_list): for abstract_struct in abstract_list: abs_format = abstract_struct['format'] content_type = abstract_struct['text_type'] content_zipped = abstract_struct['content'] ...
[ "Preprocess abstracts in database pickle dump format for ISI reader.\n\n For each abstract, creates a plain text file with one sentence per\n line, and stores metadata to be included with each statement from\n that abstract.\n\n Parameters\n ----------\n abstract_list : lis...
Please provide a description of the function:def process_geneways_files(input_folder=data_folder, get_evidence=True): gp = GenewaysProcessor(input_folder, get_evidence) return gp
[ "Reads in Geneways data and returns a list of statements.\n\n Parameters\n ----------\n input_folder : Optional[str]\n A folder in which to search for Geneways data. Looks for these\n Geneways extraction data files: human_action.txt,\n human_actionmention.txt, human_symbols.txt.\n ...
Please provide a description of the function:def post_update(self, post_id, tag_string=None, rating=None, source=None, parent_id=None, has_embedded_notes=None, is_rating_locked=None, is_note_locked=None, is_status_locked=None): params = { ...
[ "Update a specific post (Requires login).\n\n Parameters:\n post_id (int): The id number of the post to update.\n tag_string (str): A space delimited list of tags.\n rating (str): The rating for the post. Can be: safe, questionable,\n or explicit.\n ...
Please provide a description of the function:def post_revert(self, post_id, version_id): return self._get('posts/{0}/revert.json'.format(post_id), {'version_id': version_id}, 'PUT', auth=True)
[ "Function to reverts a post to a previous version (Requires login).\n\n Parameters:\n post_id (int):\n version_id (int): The post version id to revert to.\n " ]
Please provide a description of the function:def post_copy_notes(self, post_id, other_post_id): return self._get('posts/{0}/copy_notes.json'.format(post_id), {'other_post_id': other_post_id}, 'PUT', auth=True)
[ "Function to copy notes (requires login).\n\n Parameters:\n post_id (int):\n other_post_id (int): The id of the post to copy notes to.\n " ]
Please provide a description of the function:def post_mark_translated(self, post_id, check_translation, partially_translated): param = { 'post[check_translation]': check_translation, 'post[partially_translated]': partially_translated } ...
[ "Mark post as translated (Requires login) (UNTESTED).\n\n If you set check_translation and partially_translated to 1 post will\n be tagged as 'translated_request'\n\n Parameters:\n post_id (int):\n check_translation (int): Can be 0, 1.\n partially_translated (in...
Please provide a description of the function:def post_vote(self, post_id, score): return self._get('posts/{0}/votes.json'.format(post_id), {'score': score}, 'POST', auth=True)
[ "Action lets you vote for a post (Requires login).\n Danbooru: Post votes/create.\n\n Parameters:\n post_id (int):\n score (str): Can be: up, down.\n " ]
Please provide a description of the function:def post_unvote(self, post_id): return self._get('posts/{0}/unvote.json'.format(post_id), method='PUT', auth=True)
[ "Action lets you unvote for a post (Requires login).\n\n Parameters:\n post_id (int):\n " ]
Please provide a description of the function:def post_flag_list(self, creator_id=None, creator_name=None, post_id=None, reason_matches=None, is_resolved=None, category=None): params = { 'search[creator_id]': creator_id, 'search[creator_name]': creator_name...
[ "Function to flag a post (Requires login).\n\n Parameters:\n creator_id (int): The user id of the flag's creator.\n creator_name (str): The name of the flag's creator.\n post_id (int): The post id if the flag.\n " ]
Please provide a description of the function:def post_flag_create(self, post_id, reason): params = {'post_flag[post_id]': post_id, 'post_flag[reason]': reason} return self._get('post_flags.json', params, 'POST', auth=True)
[ "Function to flag a post.\n\n Parameters:\n post_id (int): The id of the flagged post.\n reason (str): The reason of the flagging.\n " ]
Please provide a description of the function:def post_appeals_list(self, creator_id=None, creator_name=None, post_id=None): params = { 'creator_id': creator_id, 'creator_name': creator_name, 'post_id': post_id } return se...
[ "Function to return list of appeals (Requires login).\n\n Parameters:\n creator_id (int): The user id of the appeal's creator.\n creator_name (str): The name of the appeal's creator.\n post_id (int): The post id if the appeal.\n " ]
Please provide a description of the function:def post_appeals_create(self, post_id, reason): params = {'post_appeal[post_id]': post_id, 'post_appeal[reason]': reason} return self._get('post_appeals.json', params, 'POST', auth=True)
[ "Function to create appeals (Requires login).\n\n Parameters:\n post_id (int): The id of the appealed post.\n reason (str) The reason of the appeal.\n " ]
Please provide a description of the function:def post_versions_list(self, updater_name=None, updater_id=None, post_id=None, start_id=None): params = { 'search[updater_name]': updater_name, 'search[updater_id]': updater_id, 'search[post_id]'...
[ "Get list of post versions.\n\n Parameters:\n updater_name (str):\n updater_id (int):\n post_id (int):\n start_id (int):\n " ]
Please provide a description of the function:def post_versions_undo(self, version_id): return self._get('post_versions/{0}/undo.json'.format(version_id), method='PUT', auth=True)
[ "Undo post version (Requires login) (UNTESTED).\n\n Parameters:\n version_id (int):\n " ]
Please provide a description of the function:def upload_list(self, uploader_id=None, uploader_name=None, source=None): params = { 'search[uploader_id]': uploader_id, 'search[uploader_name]': uploader_name, 'search[source]': source } return self._g...
[ "Search and return an uploads list (Requires login).\n\n Parameters:\n uploader_id (int): The id of the uploader.\n uploader_name (str): The name of the uploader.\n source (str): The source of the upload (exact string match).\n " ]
Please provide a description of the function:def upload_create(self, tags, rating, file_=None, source=None, parent_id=None): if file_ or source is not None: params = { 'upload[source]': source, 'upload[rating]': rating, '...
[ "Function to create a new upload (Requires login).\n\n Parameters:\n tags (str):\n rating (str): Can be: `s`, `q`, or `e`. Alternatively, you can\n specify `rating:safe`, `rating:questionable`, or\n `rating:explicit` in the tag string.\n...
Please provide a description of the function:def comment_list(self, group_by, limit=None, page=None, body_matches=None, post_id=None, post_tags_match=None, creator_name=None, creator_id=None, is_deleted=None): params = { 'group_by': group_by, ...
[ "Return a list of comments.\n\n Parameters:\n limit (int): How many posts you want to retrieve.\n page (int): The page number.\n group_by: Can be 'comment', 'post'. Comment will return recent\n comments. Post will return posts that have been recently\n ...
Please provide a description of the function:def comment_create(self, post_id, body, do_not_bump_post=None): params = { 'comment[post_id]': post_id, 'comment[body]': body, 'comment[do_not_bump_post]': do_not_bump_post } return self._get('comments....
[ "Action to lets you create a comment (Requires login).\n\n Parameters:\n post_id (int):\n body (str):\n do_not_bump_post (bool): Set to 1 if you do not want the post to be\n bumped to the top of the comment listing.\n " ]
Please provide a description of the function:def comment_update(self, comment_id, body): params = {'comment[body]': body} return self._get('comments/{0}.json'.format(comment_id), params, 'PUT', auth=True)
[ "Function to update a comment (Requires login).\n\n Parameters:\n comment_id (int):\n body (str):\n " ]
Please provide a description of the function:def comment_delete(self, comment_id): return self._get('comments/{0}.json'.format(comment_id), method='DELETE', auth=True)
[ "Remove a specific comment (Requires login).\n\n Parameters:\n comment_id (int): The id number of the comment to remove.\n " ]
Please provide a description of the function:def comment_undelete(self, comment_id): return self._get('comments/{0}/undelete.json'.format(comment_id), method='POST', auth=True)
[ "Undelete a specific comment (Requires login) (UNTESTED).\n\n Parameters:\n comment_id (int):\n " ]
Please provide a description of the function:def comment_vote(self, comment_id, score): params = {'score': score} return self._get('comments/{0}/votes.json'.format(comment_id), params, method='POST', auth=True)
[ "Lets you vote for a comment (Requires login).\n\n Parameters:\n comment_id (int):\n score (str): Can be: up, down.\n " ]
Please provide a description of the function:def comment_unvote(self, comment_id): return self._get('posts/{0}/unvote.json'.format(comment_id), method='POST', auth=True)
[ "Lets you unvote a specific comment (Requires login).\n\n Parameters:\n comment_id (int):\n " ]
Please provide a description of the function:def favorite_remove(self, post_id): return self._get('favorites/{0}.json'.format(post_id), method='DELETE', auth=True)
[ "Remove a post from favorites (Requires login).\n\n Parameters:\n post_id (int): Where post_id is the post id.\n " ]
Please provide a description of the function:def dmail_list(self, message_matches=None, to_name=None, to_id=None, from_name=None, from_id=None, read=None): params = { 'search[message_matches]': message_matches, 'search[to_name]': to_name, 'search[t...
[ "Return list of Dmails. You can only view dmails you own\n (Requires login).\n\n Parameters:\n message_matches (str): The message body contains the given terms.\n to_name (str): The recipient's name.\n to_id (int): The recipient's user id.\n from_name (str):...
Please provide a description of the function:def dmail_create(self, to_name, title, body): params = { 'dmail[to_name]': to_name, 'dmail[title]': title, 'dmail[body]': body } return self._get('dmails.json', params, 'POST', auth=True)
[ "Create a dmail (Requires login)\n\n Parameters:\n to_name (str): The recipient's name.\n title (str): The title of the message.\n body (str): The body of the message.\n " ]
Please provide a description of the function:def dmail_delete(self, dmail_id): return self._get('dmails/{0}.json'.format(dmail_id), method='DELETE', auth=True)
[ "Delete a dmail. You can only delete dmails you own (Requires login).\n\n Parameters:\n dmail_id (int): where dmail_id is the dmail id.\n " ]
Please provide a description of the function:def artist_list(self, query=None, artist_id=None, creator_name=None, creator_id=None, is_active=None, is_banned=None, empty_only=None, order=None): params = { 'search[name]': query, 'search[id]'...
[ "Get an artist of a list of artists.\n\n Parameters:\n query (str):\n This field has multiple uses depending on what the query starts\n with:\n 'http:desired_url':\n Search for artist with this URL.\n 'name:desired_url'...
Please provide a description of the function:def artist_create(self, name, other_names_comma=None, group_name=None, url_string=None, body=None): params = { 'artist[name]': name, 'artist[other_names_comma]': other_names_comma, 'artist[group_name]...
[ "Function to create an artist (Requires login) (UNTESTED).\n\n Parameters:\n name (str):\n other_names_comma (str): List of alternative names for this\n artist, comma delimited.\n group_name (str): The name of the group this artist belongs ...
Please provide a description of the function:def artist_update(self, artist_id, name=None, other_names_comma=None, group_name=None, url_string=None, body=None): params = { 'artist[name]': name, 'artist[other_names_comma]': other_names_comma, 'ar...
[ "Function to update artists (Requires login) (UNTESTED).\n\n Parameters:\n artist_id (str):\n name (str): Artist name.\n other_names_comma (str): List of alternative names for this\n artist, comma delimited.\n group_name (str): T...
Please provide a description of the function:def artist_delete(self, artist_id): return self._get('artists/{0}.json'.format(artist_id), method='DELETE', auth=True)
[ "Action to lets you delete an artist (Requires login) (UNTESTED)\n (Only Builder+).\n\n Parameters:\n artist_id (int): Where artist_id is the artist id.\n " ]
Please provide a description of the function:def artist_undelete(self, artist_id): return self._get('artists/{0}/undelete.json'.format(artist_id), method='POST', auth=True)
[ "Lets you undelete artist (Requires login) (UNTESTED) (Only Builder+).\n\n Parameters:\n artist_id (int):\n " ]
Please provide a description of the function:def artist_revert(self, artist_id, version_id): params = {'version_id': version_id} return self._get('artists/{0}/revert.json'.format(artist_id), params, method='PUT', auth=True)
[ "Revert an artist (Requires login) (UNTESTED).\n\n Parameters:\n artist_id (int): The artist id.\n version_id (int): The artist version id to revert to.\n " ]
Please provide a description of the function:def artist_versions(self, name=None, updater_name=None, updater_id=None, artist_id=None, is_active=None, is_banned=None, order=None): params = { 'search[name]': name, 'search[updater_nam...
[ "Get list of artist versions (Requires login).\n\n Parameters:\n name (str):\n updater_name (str):\n updater_id (int):\n artist_id (int):\n is_active (bool): Can be: True, False.\n is_banned (bool): Can be: True, False.\n order (str...
Please provide a description of the function:def artist_commentary_list(self, text_matches=None, post_id=None, post_tags_match=None, original_present=None, translated_present=None): params = { 'search[text_matches]': text_matches...
[ "list artist commentary.\n\n Parameters:\n text_matches (str):\n post_id (int):\n post_tags_match (str): The commentary's post's tags match the\n giventerms. Meta-tags not supported.\n original_present (str): Can be: yes, no.\n ...
Please provide a description of the function:def artist_commentary_create_update(self, post_id, original_title, original_description, translated_title, translated_description): params = { 'artist_commentary[post...
[ "Create or update artist commentary (Requires login) (UNTESTED).\n\n Parameters:\n post_id (int): Post id.\n original_title (str): Original title.\n original_description (str): Original description.\n translated_title (str): Translated title.\n translate...
Please provide a description of the function:def artist_commentary_revert(self, id_, version_id): params = {'version_id': version_id} return self._get('artist_commentaries/{0}/revert.json'.format(id_), params, method='PUT', auth=True)
[ "Revert artist commentary (Requires login) (UNTESTED).\n\n Parameters:\n id_ (int): The artist commentary id.\n version_id (int): The artist commentary version id to\n revert to.\n " ]
Please provide a description of the function:def artist_commentary_versions(self, post_id, updater_id): params = {'search[updater_id]': updater_id, 'search[post_id]': post_id} return self._get('artist_commentary_versions.json', params)
[ "Return list of artist commentary versions.\n\n Parameters:\n updater_id (int):\n post_id (int):\n " ]
Please provide a description of the function:def note_list(self, body_matches=None, post_id=None, post_tags_match=None, creator_name=None, creator_id=None, is_active=None): params = { 'search[body_matches]': body_matches, 'search[post_id]': post_id, ...
[ "Return list of notes.\n\n Parameters:\n body_matches (str): The note's body matches the given terms.\n post_id (int): A specific post.\n post_tags_match (str): The note's post's tags match the given terms.\n creator_name (str): The creator's name. Exact match.\n ...
Please provide a description of the function:def note_create(self, post_id, coor_x, coor_y, width, height, body): params = { 'note[post_id]': post_id, 'note[x]': coor_x, 'note[y]': coor_y, 'note[width]': width, 'note[height]': height, ...
[ "Function to create a note (Requires login) (UNTESTED).\n\n Parameters:\n post_id (int):\n coor_x (int): The x coordinates of the note in pixels,\n with respect to the top-left corner of the image.\n coor_y (int): The y coordinates of the note in pixe...
Please provide a description of the function:def note_update(self, note_id, coor_x=None, coor_y=None, width=None, height=None, body=None): params = { 'note[x]': coor_x, 'note[y]': coor_y, 'note[width]': width, 'note[height]': height, ...
[ "Function to update a note (Requires login) (UNTESTED).\n\n Parameters:\n note_id (int): Where note_id is the note id.\n coor_x (int): The x coordinates of the note in pixels,\n with respect to the top-left corner of the image.\n coor_y (int): The y c...
Please provide a description of the function:def note_delete(self, note_id): return self._get('notes/{0}.json'.format(note_id), method='DELETE', auth=True)
[ "delete a specific note (Requires login) (UNTESTED).\n\n Parameters:\n note_id (int): Where note_id is the note id.\n " ]
Please provide a description of the function:def note_revert(self, note_id, version_id): return self._get('notes/{0}/revert.json'.format(note_id), {'version_id': version_id}, method='PUT', auth=True)
[ "Function to revert a specific note (Requires login) (UNTESTED).\n\n Parameters:\n note_id (int): Where note_id is the note id.\n version_id (int): The note version id to revert to.\n " ]
Please provide a description of the function:def note_versions(self, updater_id=None, post_id=None, note_id=None): params = { 'search[updater_id]': updater_id, 'search[post_id]': post_id, 'search[note_id]': note_id } return self._get('note_version...
[ "Get list of note versions.\n\n Parameters:\n updater_id (int):\n post_id (int):\n note_id (int):\n " ]
Please provide a description of the function:def user_list(self, name=None, name_matches=None, min_level=None, max_level=None, level=None, user_id=None, order=None): params = { 'search[name]': name, 'search[name_matches]': name_matches, 'search[min_...
[ "Function to get a list of users or a specific user.\n\n Levels:\n Users have a number attribute called level representing their role.\n The current levels are:\n\n Member 20, Gold 30, Platinum 31, Builder 32, Contributor 33,\n Janitor 35, Moderator 40 and Admin 50...