_id
stringlengths
2
7
title
stringlengths
1
88
partition
stringclasses
3 values
text
stringlengths
75
19.8k
language
stringclasses
1 value
meta_information
dict
q57700
singleton
train
def singleton(the_class): """ Decorator for a class to make a singleton out of it. @type the_class: class @param the_class: the class that should work as a singleton @rtype: decorator @return: decorator """ class_instances = {} def get_instance(*args, **kwargs): """ ...
python
{ "resource": "" }
q57701
build_board_2048
train
def build_board_2048(): """ builds a 2048 starting board Printing Grid 0 0 0 2 0 0 4 0 0 0 0 0 0 0 0 0 """ grd = Grid(4,4, [2,4]) grd.new_tile() grd.new_tile() print(grd) return grd
python
{ "resource": "" }
q57702
build_board_checkers
train
def build_board_checkers(): """ builds a checkers starting board Printing Grid 0 B 0 B 0 B 0 B B 0 B 0 B 0 B 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0...
python
{ "resource": "" }
q57703
TEST
train
def TEST(): """ tests for this module """ grd = Grid(4,4, [2,4]) grd.new_tile() grd.new_tile() print(grd) print("There are ", grd.count_blank_positions(), " blanks in grid 1\n") grd2 = Grid(5,5, ['A','B']) grd2.new_tile(26) print(grd2) build_board_checkers() print("There ar...
python
{ "resource": "" }
q57704
GoogleCloudStorage.url
train
def url(self, name): """ Ask blobstore api for an url to directly serve the file """ key = blobstore.create_gs_key('/gs' + name) return images.get_serving_url(key)
python
{ "resource": "" }
q57705
Stage.process
train
def process(self, stage): """Processing one stage.""" self.logger.info("Processing pipeline stage '%s'", self.title) output = [] for entry in stage: key = list(entry.keys())[0] if key == "env": self.pipeline.data.env_list[1].update(entry[key]) ...
python
{ "resource": "" }
q57706
MarketClient.trading_fees
train
def trading_fees(self) -> TradingFees: """Fetch trading fees.""" return self._fetch('trading fees', self.market.code)(self._trading_fees)()
python
{ "resource": "" }
q57707
MarketClient.fetch_ticker
train
def fetch_ticker(self) -> Ticker: """Fetch the market ticker.""" return self._fetch('ticker', self.market.code)(self._ticker)()
python
{ "resource": "" }
q57708
MarketClient.fetch_order_book
train
def fetch_order_book(self) -> OrderBook: """Fetch the order book.""" return self._fetch('order book', self.market.code)(self._order_book)()
python
{ "resource": "" }
q57709
MarketClient.fetch_trades_since
train
def fetch_trades_since(self, since: int) -> List[Trade]: """Fetch trades since given timestamp.""" return self._fetch_since('trades', self.market.code)(self._trades_since)(since)
python
{ "resource": "" }
q57710
WalletClient.fetch_deposits
train
def fetch_deposits(self, limit: int) -> List[Deposit]: """Fetch latest deposits, must provide a limit.""" return self._transactions(self._deposits, 'deposits', limit)
python
{ "resource": "" }
q57711
WalletClient.fetch_deposits_since
train
def fetch_deposits_since(self, since: int) -> List[Deposit]: """Fetch all deposits since the given timestamp.""" return self._transactions_since(self._deposits_since, 'deposits', since)
python
{ "resource": "" }
q57712
WalletClient.fetch_withdrawals
train
def fetch_withdrawals(self, limit: int) -> List[Withdrawal]: """Fetch latest withdrawals, must provide a limit.""" return self._transactions(self._withdrawals, 'withdrawals', limit)
python
{ "resource": "" }
q57713
WalletClient.fetch_withdrawals_since
train
def fetch_withdrawals_since(self, since: int) -> List[Withdrawal]: """Fetch all withdrawals since the given timestamp.""" return self._transactions_since(self._withdrawals_since, 'withdrawals', since)
python
{ "resource": "" }
q57714
WalletClient.request_withdrawal
train
def request_withdrawal(self, amount: Number, address: str, subtract_fee: bool=False, **params) -> Withdrawal: """Request a withdrawal.""" self.log.debug(f'Requesting {self.currency} withdrawal from {self.name} to {address}') amount = self._parse_money(amount) if self.dry_run: ...
python
{ "resource": "" }
q57715
TradingClient.fetch_order
train
def fetch_order(self, order_id: str) -> Order: """Fetch an order by ID.""" return self._fetch(f'order id={order_id}', exc=OrderNotFound)(self._order)(order_id)
python
{ "resource": "" }
q57716
TradingClient.fetch_open_orders
train
def fetch_open_orders(self, limit: int) -> List[Order]: """Fetch latest open orders, must provide a limit.""" return self._fetch_orders_limit(self._open_orders, limit)
python
{ "resource": "" }
q57717
TradingClient.fetch_closed_orders
train
def fetch_closed_orders(self, limit: int) -> List[Order]: """Fetch latest closed orders, must provide a limit.""" return self._fetch_orders_limit(self._closed_orders, limit)
python
{ "resource": "" }
q57718
TradingClient.fetch_closed_orders_since
train
def fetch_closed_orders_since(self, since: int) -> List[Order]: """Fetch closed orders since the given timestamp.""" return self._fetch_orders_since(self._closed_orders_since, since)
python
{ "resource": "" }
q57719
TradingClient.cancel_order
train
def cancel_order(self, order_id: str) -> str: """Cancel an order by ID.""" self.log.debug(f'Canceling order id={order_id} on {self.name}') if self.dry_run: # Don't cancel if dry run self.log.warning(f'DRY RUN: Order cancelled on {self.name}: id={order_id}') return order...
python
{ "resource": "" }
q57720
TradingClient.cancel_orders
train
def cancel_orders(self, order_ids: List[str]) -> List[str]: """Cancel multiple orders by a list of IDs.""" orders_to_cancel = order_ids self.log.debug(f'Canceling orders on {self.name}: ids={orders_to_cancel}') cancelled_orders = [] if self.dry_run: # Don't cancel if dry run ...
python
{ "resource": "" }
q57721
TradingClient.cancel_all_orders
train
def cancel_all_orders(self) -> List[str]: """Cancel all open orders.""" order_ids = [o.id for o in self.fetch_all_open_orders()] return self.cancel_orders(order_ids)
python
{ "resource": "" }
q57722
TradingClient.min_order_amount
train
def min_order_amount(self) -> Money: """Minimum amount to place an order.""" return self._fetch('minimum order amount', self.market.code)(self._min_order_amount)()
python
{ "resource": "" }
q57723
TradingClient.place_market_order
train
def place_market_order(self, side: Side, amount: Number) -> Order: """Place a market order.""" return self.place_order(side, OrderType.MARKET, amount)
python
{ "resource": "" }
q57724
main
train
def main(): """ This is the main module for the script. The script will accept a file, or a directory, and then encrypt it with a provided key before pushing it to S3 into a specified bucket. """ parser = argparse.ArgumentParser(description=main.__doc__, add_help=True) parser.add_argument('-M',...
python
{ "resource": "" }
q57725
BucketInfo._get_bucket_endpoint
train
def _get_bucket_endpoint(self): """ Queries S3 to identify the region hosting the provided bucket. """ conn = S3Connection() bucket = conn.lookup(self.bucket_name) if not bucket: # TODO: Make the bucket here? raise InputParameterError('The provided...
python
{ "resource": "" }
q57726
align_rna
train
def align_rna(job, fastqs, univ_options, star_options): """ A wrapper for the entire rna alignment subgraph. :param list fastqs: The input fastqs for alignment :param dict univ_options: Dict of universal options used by almost all tools :param dict star_options: Options specific to star :return...
python
{ "resource": "" }
q57727
run_star
train
def run_star(job, fastqs, univ_options, star_options): """ Align a pair of fastqs with STAR. :param list fastqs: The input fastqs for alignment :param dict univ_options: Dict of universal options used by almost all tools :param dict star_options: Options specific to star :return: Dict containin...
python
{ "resource": "" }
q57728
sort_and_index_star
train
def sort_and_index_star(job, star_bams, univ_options, star_options): """ A wrapper for sorting and indexing the genomic star bam generated by run_star. It is required since run_star returns a dict of 2 bams :param dict star_bams: The bams from run_star :param dict univ_options: Dict of universal op...
python
{ "resource": "" }
q57729
Expectation.reset
train
def reset(self): """ Resets the state of the expression """ self.expr = [] self.matcher = None self.last_matcher = None self.description = None
python
{ "resource": "" }
q57730
Expectation.clone
train
def clone(self): """ Clone this expression """ from copy import copy clone = copy(self) clone.expr = copy(self.expr) clone.factory = False return clone
python
{ "resource": "" }
q57731
Expectation.resolve
train
def resolve(self, value=None): """ Resolve the current expression against the supplied value """ # If we still have an uninitialized matcher init it now if self.matcher: self._init_matcher() # Evaluate the current set of matchers forming the expression matcher = sel...
python
{ "resource": "" }
q57732
Expectation._assertion
train
def _assertion(self, matcher, value): """ Perform the actual assertion for the given matcher and value. Override this method to apply a special configuration when performing the assertion. If the assertion fails it should raise an AssertionError. """ # To support the synt...
python
{ "resource": "" }
q57733
Expectation._transform
train
def _transform(self, value): """ Applies any defined transformation to the given value """ if self.transform: try: value = self.transform(value) except: import sys exc_type, exc_obj, exc_tb = sys.exc_info() r...
python
{ "resource": "" }
q57734
Expectation.evaluate
train
def evaluate(self): """ Converts the current expression into a single matcher, applying coordination operators to operands according to their binding rules """ # Apply Shunting Yard algorithm to convert the infix expression # into Reverse Polish Notation. Since we have a ver...
python
{ "resource": "" }
q57735
Expectation._find_matcher
train
def _find_matcher(self, alias): """ Finds a matcher based on the given alias or raises an error if no matcher could be found. """ matcher = lookup(alias) if not matcher: msg = 'Matcher "%s" not found' % alias # Try to find similarly named matchers to ...
python
{ "resource": "" }
q57736
Expectation._init_matcher
train
def _init_matcher(self, *args, **kwargs): """ Executes the current matcher appending it to the expression """ # If subject-less expectation are provided as arguments convert them # to plain Hamcrest matchers in order to allow complex compositions fn = lambda x: x.evaluate() if isinstanc...
python
{ "resource": "" }
q57737
Expectation.described_as
train
def described_as(self, description, *args): """ Specify a custom message for the matcher """ if len(args): description = description.format(*args) self.description = description return self
python
{ "resource": "" }
q57738
make_dbsource
train
def make_dbsource(**kwargs): """Returns a mapnik PostGIS or SQLite Datasource.""" if 'spatialite' in connection.settings_dict.get('ENGINE'): kwargs.setdefault('file', connection.settings_dict['NAME']) return mapnik.SQLite(wkb_format='spatialite', **kwargs) names = (('dbname', 'NAME'), ('user...
python
{ "resource": "" }
q57739
Map.layer
train
def layer(self, queryset, stylename=None): """Returns a map Layer. Arguments: queryset -- QuerySet for Layer Keyword args: stylename -- str name of style to apply """ cls = RasterLayer if hasattr(queryset, 'image') else VectorLayer layer = cls(queryset, s...
python
{ "resource": "" }
q57740
Map.zoom_bbox
train
def zoom_bbox(self, bbox): """Zoom map to geometry extent. Arguments: bbox -- OGRGeometry polygon to zoom map extent """ try: bbox.transform(self.map.srs) except gdal.GDALException: pass else: self.map.zoom_to_box(mapnik.Box2d(...
python
{ "resource": "" }
q57741
Layer.style
train
def style(self): """Returns a default Style.""" style = mapnik.Style() rule = mapnik.Rule() self._symbolizer = self.symbolizer() rule.symbols.append(self._symbolizer) style.rules.append(rule) return style
python
{ "resource": "" }
q57742
wrap_fusion
train
def wrap_fusion(job, fastqs, star_output, univ_options, star_fusion_options, fusion_inspector_options): """ A wrapper for run_fusion using the results from cutadapt and star as input. :param tuple fastqs: RNA-Seq FASTQ Filestor...
python
{ "resource": "" }
q57743
parse_star_fusion
train
def parse_star_fusion(infile): """ Parses STAR-Fusion format and returns an Expando object with basic features :param str infile: path to STAR-Fusion prediction file :return: Fusion prediction attributes :rtype: bd2k.util.expando.Expando """ reader = csv.reader(infile, delimiter='\t') h...
python
{ "resource": "" }
q57744
get_transcripts
train
def get_transcripts(transcript_file): """ Parses FusionInspector transcript file and returns dictionary of sequences :param str transcript_file: path to transcript FASTA :return: de novo assembled transcripts :rtype: dict """ with open(transcript_file, 'r') as fa: transcripts = {} ...
python
{ "resource": "" }
q57745
split_fusion_transcript
train
def split_fusion_transcript(annotation_path, transcripts): """ Finds the breakpoint in the fusion transcript and splits the 5' donor from the 3' acceptor :param str annotation_path: Path to transcript annotation file :param dict transcripts: Dictionary of fusion transcripts :return: 5' donor sequen...
python
{ "resource": "" }
q57746
get_gene_ids
train
def get_gene_ids(fusion_bed): """ Parses FusionInspector bed file to ascertain the ENSEMBL gene ids :param str fusion_bed: path to fusion annotation :return: dict """ with open(fusion_bed, 'r') as f: gene_to_id = {} regex = re.compile(r'(?P<gene>ENSG\d*)') for line in f:...
python
{ "resource": "" }
q57747
reformat_star_fusion_output
train
def reformat_star_fusion_output(job, fusion_annot, fusion_file, transcript_file, transcript_gff_file, univ_options): """ Writes STAR-Fusion results in T...
python
{ "resource": "" }
q57748
_ensure_patient_group_is_ok
train
def _ensure_patient_group_is_ok(patient_object, patient_name=None): """ Ensure that the provided entries for the patient groups is formatted properly. :param set|dict patient_object: The values passed to the samples patient group :param str patient_name: Optional name for the set :raises ParameterE...
python
{ "resource": "" }
q57749
_add_default_entries
train
def _add_default_entries(input_dict, defaults_dict): """ Add the entries in defaults dict into input_dict if they don't exist in input_dict This is based on the accepted answer at http://stackoverflow.com/questions/3232943/update-value-of-a-nested-dictionary-of-varying-depth :param dict input_dict...
python
{ "resource": "" }
q57750
_process_group
train
def _process_group(input_group, required_group, groupname, append_subgroups=None): """ Process one group from the input yaml. Ensure it has the required entries. If there is a subgroup that should be processed and then appended to the rest of the subgroups in that group, handle it accordingly. :p...
python
{ "resource": "" }
q57751
get_fastq_2
train
def get_fastq_2(job, patient_id, sample_type, fastq_1): """ For a path to a fastq_1 file, return a fastq_2 file with the same prefix and naming scheme. :param str patient_id: The patient_id :param str sample_type: The sample type of the file :param str fastq_1: The path to the fastq_1 file :ret...
python
{ "resource": "" }
q57752
parse_config_file
train
def parse_config_file(job, config_file, max_cores=None): """ Parse the config file and spawn a ProTECT job for every input sample. :param str config_file: Path to the input config file :param int max_cores: The maximum cores to use for any single high-compute job. """ sample_set, univ_options, ...
python
{ "resource": "" }
q57753
get_all_tool_inputs
train
def get_all_tool_inputs(job, tools, outer_key='', mutation_caller_list=None): """ Iterate through all the tool options and download required files from their remote locations. :param dict tools: A dict of dicts of all tools, and their options :param str outer_key: If this is being called recursively, w...
python
{ "resource": "" }
q57754
get_pipeline_inputs
train
def get_pipeline_inputs(job, input_flag, input_file, encryption_key=None, per_file_encryption=False, gdc_download_token=None): """ Get the input file from s3 or disk and write to file store. :param str input_flag: The name of the flag :param str input_file: The value passed in t...
python
{ "resource": "" }
q57755
prepare_samples
train
def prepare_samples(job, patient_dict, univ_options): """ Obtain the input files for the patient and write them to the file store. :param dict patient_dict: The input fastq dict patient_dict: |- 'tumor_dna_fastq_[12]' OR 'tumor_dna_bam': str |- 'tumor_rna_fastq_[12]...
python
{ "resource": "" }
q57756
get_patient_bams
train
def get_patient_bams(job, patient_dict, sample_type, univ_options, bwa_options, mutect_options): """ Convenience function to return the bam and its index in the correct format for a sample type. :param dict patient_dict: dict of patient info :param str sample_type: 'tumor_rna', 'tumor_dna', 'normal_dna...
python
{ "resource": "" }
q57757
get_patient_vcf
train
def get_patient_vcf(job, patient_dict): """ Convenience function to get the vcf from the patient dict :param dict patient_dict: dict of patient info :return: The vcf :rtype: toil.fileStore.FileID """ temp = job.fileStore.readGlobalFile(patient_dict['mutation_vcf'], ...
python
{ "resource": "" }
q57758
get_patient_mhc_haplotype
train
def get_patient_mhc_haplotype(job, patient_dict): """ Convenience function to get the mhc haplotype from the patient dict :param dict patient_dict: dict of patient info :return: The MHCI and MHCII haplotypes :rtype: toil.fileStore.FileID """ haplotype_archive = job.fileStore.readGlobalFile(...
python
{ "resource": "" }
q57759
get_patient_expression
train
def get_patient_expression(job, patient_dict): """ Convenience function to get the expression from the patient dict :param dict patient_dict: dict of patient info :return: The gene and isoform expression :rtype: toil.fileStore.FileID """ expression_archive = job.fileStore.readGlobalFile(pat...
python
{ "resource": "" }
q57760
generate_config_file
train
def generate_config_file(): """ Generate a config file for a ProTECT run on hg19. :return: None """ shutil.copy(os.path.join(os.path.dirname(__file__), 'input_parameters.yaml'), os.path.join(os.getcwd(), 'ProTECT_config.yaml'))
python
{ "resource": "" }
q57761
main
train
def main(): """ This is the main function for ProTECT. """ parser = argparse.ArgumentParser(prog='ProTECT', description='Prediction of T-Cell Epitopes for Cancer Therapy', epilog='Contact Arjun Rao (aarao@ucsc.edu) if you encounte...
python
{ "resource": "" }
q57762
Server.poll
train
def poll(self): """ Poll Check for a non-response string generated by LCDd and return any string read. LCDd generates strings for key presses, menu events & screen visibility changes. """ if select.select([self.tn], [], [], 0) == ([self.tn], [], []): ...
python
{ "resource": "" }
q57763
module_to_dict
train
def module_to_dict(module, omittable=lambda k: k.startswith('_')): """ Converts a module namespace to a Python dictionary. Used by get_settings_diff. """ return dict([(k, repr(v)) for k, v in module.__dict__.items() if not omittable(k)])
python
{ "resource": "" }
q57764
run_snpeff
train
def run_snpeff(job, merged_mutation_file, univ_options, snpeff_options): """ Run snpeff on an input vcf. :param toil.fileStore.FileID merged_mutation_file: fsID for input vcf :param dict univ_options: Dict of universal options used by almost all tools :param dict snpeff_options: Options specific to...
python
{ "resource": "" }
q57765
paths_in_directory
train
def paths_in_directory(input_directory): """ Generate a list of all files in input_directory, each as a list containing path components. """ paths = [] for base_path, directories, filenames in os.walk(input_directory): relative_path = os.path.relpath(base_path, input_directory) path_...
python
{ "resource": "" }
q57766
run_car_t_validity_assessment
train
def run_car_t_validity_assessment(job, rsem_files, univ_options, reports_options): """ A wrapper for assess_car_t_validity. :param dict rsem_files: Results from running rsem :param dict univ_options: Dict of universal options used by almost all tools :param dict reports_options: Options specific to...
python
{ "resource": "" }
q57767
align_dna
train
def align_dna(job, fastqs, sample_type, univ_options, bwa_options): """ A wrapper for the entire dna alignment subgraph. :param list fastqs: The input fastqs for alignment :param str sample_type: Description of the sample to inject into the filename :param dict univ_options: Dict of universal optio...
python
{ "resource": "" }
q57768
run_bwa
train
def run_bwa(job, fastqs, sample_type, univ_options, bwa_options): """ Align a pair of fastqs with bwa. :param list fastqs: The input fastqs for alignment :param str sample_type: Description of the sample to inject into the filename :param dict univ_options: Dict of universal options used by almost ...
python
{ "resource": "" }
q57769
bam_conversion
train
def bam_conversion(job, samfile, sample_type, univ_options, samtools_options): """ Convert a sam to a bam. :param dict samfile: The input sam file :param str sample_type: Description of the sample to inject into the filename :param dict univ_options: Dict of universal options used by almost all too...
python
{ "resource": "" }
q57770
fix_bam_header
train
def fix_bam_header(job, bamfile, sample_type, univ_options, samtools_options, retained_chroms=None): """ Fix the bam header to remove the command line call. Failing to do this causes Picard to reject the bam. :param dict bamfile: The input bam file :param str sample_type: Description of the sample...
python
{ "resource": "" }
q57771
add_readgroups
train
def add_readgroups(job, bamfile, sample_type, univ_options, picard_options): """ Add read groups to the bam. :param dict bamfile: The input bam file :param str sample_type: Description of the sample to inject into the filename :param dict univ_options: Dict of universal options used by almost all t...
python
{ "resource": "" }
q57772
NepCal.weekday
train
def weekday(cls, year, month, day): """Returns the weekday of the date. 0 = aaitabar""" return NepDate.from_bs_date(year, month, day).weekday()
python
{ "resource": "" }
q57773
NepCal.monthrange
train
def monthrange(cls, year, month): """Returns the number of days in a month""" functions.check_valid_bs_range(NepDate(year, month, 1)) return values.NEPALI_MONTH_DAY_DATA[year][month - 1]
python
{ "resource": "" }
q57774
NepCal.itermonthdays
train
def itermonthdays(cls, year, month): """Similar to itermonthdates but returns day number instead of NepDate object """ for day in NepCal.itermonthdates(year, month): if day.month == month: yield day.day else: yield 0
python
{ "resource": "" }
q57775
NepCal.itermonthdays2
train
def itermonthdays2(cls, year, month): """Similar to itermonthdays2 but returns tuples of day and weekday. """ for day in NepCal.itermonthdates(year, month): if day.month == month: yield (day.day, day.weekday()) else: yield (0, day.weekday()...
python
{ "resource": "" }
q57776
NepCal.monthdatescalendar
train
def monthdatescalendar(cls, year, month): """ Returns a list of week in a month. A week is a list of NepDate objects """ weeks = [] week = [] for day in NepCal.itermonthdates(year, month): week.append(day) if len(week) == 7: weeks.append(week) ...
python
{ "resource": "" }
q57777
NepCal.monthdayscalendar
train
def monthdayscalendar(cls, year, month): """Return a list of the weeks in the month month of the year as full weeks. Weeks are lists of seven day numbers.""" weeks = [] week = [] for day in NepCal.itermonthdays(year, month): week.append(day) if len(week) =...
python
{ "resource": "" }
q57778
NepCal.monthdays2calendar
train
def monthdays2calendar(cls, year, month): """ Return a list of the weeks in the month month of the year as full weeks. Weeks are lists of seven tuples of day numbers and weekday numbers. """ weeks = [] week = [] for day in NepCal.itermonthdays2(year, month): week.appe...
python
{ "resource": "" }
q57779
run_somaticsniper_with_merge
train
def run_somaticsniper_with_merge(job, tumor_bam, normal_bam, univ_options, somaticsniper_options): """ A wrapper for the the entire SomaticSniper sub-graph. :param dict tumor_bam: Dict of bam and bai for tumor DNA-Seq :param dict normal_bam: Dict of bam and bai for normal DNA-Seq :param dict univ_o...
python
{ "resource": "" }
q57780
run_somaticsniper
train
def run_somaticsniper(job, tumor_bam, normal_bam, univ_options, somaticsniper_options, split=True): """ Run the SomaticSniper subgraph on the DNA bams. Optionally split the results into per-chromosome vcfs. :param dict tumor_bam: Dict of bam and bai for tumor DNA-Seq :param dict normal_bam: Dict o...
python
{ "resource": "" }
q57781
run_somaticsniper_full
train
def run_somaticsniper_full(job, tumor_bam, normal_bam, univ_options, somaticsniper_options): """ Run SomaticSniper on the DNA bams. :param dict tumor_bam: Dict of bam and bai for tumor DNA-Seq :param dict normal_bam: Dict of bam and bai for normal DNA-Seq :param dict univ_options: Dict of universal...
python
{ "resource": "" }
q57782
filter_somaticsniper
train
def filter_somaticsniper(job, tumor_bam, somaticsniper_output, tumor_pileup, univ_options, somaticsniper_options): """ Filter SomaticSniper calls. :param dict tumor_bam: Dict of bam and bai for tumor DNA-Seq :param toil.fileStore.FileID somaticsniper_output: SomaticSniper outpu...
python
{ "resource": "" }
q57783
run_pileup
train
def run_pileup(job, tumor_bam, univ_options, somaticsniper_options): """ Runs a samtools pileup on the tumor bam. :param dict tumor_bam: Dict of bam and bai for tumor DNA-Seq :param dict univ_options: Dict of universal options used by almost all tools :param dict somaticsniper_options: Options spec...
python
{ "resource": "" }
q57784
get_action_cache_key
train
def get_action_cache_key(name, argument): """Get an action cache key string.""" tokens = [str(name)] if argument: tokens.append(str(argument)) return '::'.join(tokens)
python
{ "resource": "" }
q57785
removed_or_inserted_action
train
def removed_or_inserted_action(mapper, connection, target): """Remove the action from cache when an item is inserted or deleted.""" current_access.delete_action_cache(get_action_cache_key(target.action, target.argument))
python
{ "resource": "" }
q57786
changed_action
train
def changed_action(mapper, connection, target): """Remove the action from cache when an item is updated.""" action_history = get_history(target, 'action') argument_history = get_history(target, 'argument') owner_history = get_history( target, 'user' if isinstance(target, ActionUsers) els...
python
{ "resource": "" }
q57787
ActionNeedMixin.allow
train
def allow(cls, action, **kwargs): """Allow the given action need. :param action: The action to allow. :returns: A :class:`invenio_access.models.ActionNeedMixin` instance. """ return cls.create(action, exclude=False, **kwargs)
python
{ "resource": "" }
q57788
ActionNeedMixin.deny
train
def deny(cls, action, **kwargs): """Deny the given action need. :param action: The action to deny. :returns: A :class:`invenio_access.models.ActionNeedMixin` instance. """ return cls.create(action, exclude=True, **kwargs)
python
{ "resource": "" }
q57789
ActionNeedMixin.query_by_action
train
def query_by_action(cls, action, argument=None): """Prepare query object with filtered action. :param action: The action to deny. :param argument: The action argument. If it's ``None`` then, if exists, the ``action.argument`` will be taken. In the worst case will be set ...
python
{ "resource": "" }
q57790
predict_mhci_binding
train
def predict_mhci_binding(job, peptfile, allele, peplen, univ_options, mhci_options): """ Predict binding for each peptide in `peptfile` to `allele` using the IEDB mhci binding prediction tool. :param toil.fileStore.FileID peptfile: The input peptide fasta :param str allele: Allele to predict bindin...
python
{ "resource": "" }
q57791
iter_and_close
train
def iter_and_close(file_like, block_size): """Yield file contents by block then close the file.""" while 1: try: block = file_like.read(block_size) if block: yield block else: raise StopIteration except StopIteration: ...
python
{ "resource": "" }
q57792
cling_wrap
train
def cling_wrap(package_name, dir_name, **kw): """Return a Cling that serves from the given package and dir_name. This uses pkg_resources.resource_filename which is not the recommended way, since it extracts the files. I think this works fine unless you have some _very_ serious requirements for sta...
python
{ "resource": "" }
q57793
Cling._is_under_root
train
def _is_under_root(self, full_path): """Guard against arbitrary file retrieval.""" if (path.abspath(full_path) + path.sep)\ .startswith(path.abspath(self.root) + path.sep): return True else: return False
python
{ "resource": "" }
q57794
Shock._match_magic
train
def _match_magic(self, full_path): """Return the first magic that matches this path or None.""" for magic in self.magics: if magic.matches(full_path): return magic
python
{ "resource": "" }
q57795
Shock._full_path
train
def _full_path(self, path_info): """Return the full path from which to read.""" full_path = self.root + path_info if path.exists(full_path): return full_path else: for magic in self.magics: if path.exists(magic.new_path(full_path)): ...
python
{ "resource": "" }
q57796
Shock._guess_type
train
def _guess_type(self, full_path): """Guess the mime type magically or using the mimetypes module.""" magic = self._match_magic(full_path) if magic is not None: return (mimetypes.guess_type(magic.old_path(full_path))[0] or 'text/plain') else: re...
python
{ "resource": "" }
q57797
Shock._conditions
train
def _conditions(self, full_path, environ): """Return Etag and Last-Modified values defaults to now for both.""" magic = self._match_magic(full_path) if magic is not None: return magic.conditions(full_path, environ) else: mtime = stat(full_path).st_mtime ...
python
{ "resource": "" }
q57798
Shock._file_like
train
def _file_like(self, full_path): """Return the appropriate file object.""" magic = self._match_magic(full_path) if magic is not None: return magic.file_like(full_path, self.encoding) else: return open(full_path, 'rb')
python
{ "resource": "" }
q57799
BaseMagic.old_path
train
def old_path(self, full_path): """Remove self.extension from path or raise MagicError.""" if self.matches(full_path): return full_path[:-len(self.extension)] else: raise MagicError("Path does not match this magic.")
python
{ "resource": "" }