Loops PSMs and outputs dictionaries passed to writer. Dictionaries
    contain the PSMs and info to which split pool the
    respective PSM belongs
420755
def generate_psms_split(fn, oldheader, bioset, splitcol):
    """"""
    try:
        splitcolnr = get_splitcolnr(oldheader, bioset, splitcol)
    except IndexError:
        raise RuntimeError('Cannot find bioset header column in '
                           'input file {}, though --bioset has '
                           'been passed'.format(fn))
    for psm in tsvreader.generate_tsv_psms(fn, oldheader):
        yield {'psm': psm,
               'split_pool': psm[oldheader[splitcolnr]]
               }
736693
def with_output
      super do |out|
        out.puts header
        @queued_write = []
        yield out
        @queued_write.sort.each do |line|
          out.puts(line)
        end
      end
    end
1165347
def execute(self, input_data):
        '''  '''

        # Aggregate the output from all the memory workers into concise summary info
        output = {'meta': input_data['mem_meta']['tables']['info']}
        output['connscan'] = list(set([item['Remote Address'] for item in input_data['mem_connscan']['tables']['connscan']]))
        pslist_md5s = {self.file_to_pid(item['filename']): item['md5'] for item in input_data['mem_procdump']['tables']['dumped_files']}
        output['pslist'] = ['PPID: %d PID: %d Name: %s - %s' % (item['PPID'], item['PID'], item['Name'], pslist_md5s[item['PID']])
                            for item in input_data['mem_pslist']['tables']['pslist']]
        return output
152168
def join(input_files, output_file):
    '''
    
    '''

    # get feature collections
    final_features = []
    for file in input_files:
        with open(file) as f:
            feat_collection = geojson.load(f)
            final_features += feat_collection['features']

    feat_collection['features'] = final_features

    # write to output file
    with open(output_file, 'w') as f:
        geojson.dump(feat_collection, f)
220760
def get_psms(self):
        """"""
        self.header = actions.create_header(self.oldheader, self.spectracol)
        self.psms = actions.generate_psms_spectradata(self.lookup, self.fn,
                                                      self.oldheader)
424314
def _pmap(self, func, items, keys, pool, bookkeeping_dict=None):
        
        if keys is not None:  # Otherwise, cannot hash items
            # Remove duplicates first (use keys)
            # Create mapping (dict) of key to list of indices
            key_indices = _duplicates(keys).values()
        else:  # Cannot hash items
            # Assume no duplicates
            key_indices = [[i] for i in range(len(items))]

        # Use only the first of duplicate indices in decoding
        if pool is not None:
            # Parallel map
            results = pool.map(
                functools.partial(_unpickle_run, pickle.dumps(func)),
                [items[i[0]] for i in key_indices])
        else:
            results = map(func, [items[i[0]] for i in key_indices])

        # Add bookkeeping
        if bookkeeping_dict is not None:
            bookkeeping_dict['key_indices'] = key_indices

        # Combine duplicates back into list
        all_results = [None] * len(items)
        for indices, result in zip(key_indices, results):
            for j, i in enumerate(indices):
                # Avoid duplicate result objects in list,
                # in case they are used in functions with side effects
                if j > 0:
                    result = copy.deepcopy(result)
                all_results[i] = result

        return all_results
221297
def _parse_queue_list(list_output):
    '''
    
    '''
    queues = dict((q.split('/')[-1], q) for q in list_output['stdout'])
    return queues
647287
def write(self, title, data, output=None):
        '''
        
        '''
        if not isinstance(data, (dict, list, tuple)):
            data = {'raw-content': str(data)}
        output = output or self.__default_outputter

        if output != 'null':
            try:
                if isinstance(data, dict) and 'return' in data:
                    data = data['return']
                content = self._printout(data, output)
            except Exception:  # Fall-back to just raw YAML
                content = None
        else:
            content = None

        if content is None:
            data = json.loads(json.dumps(data))
            if isinstance(data, dict) and data.get('return'):
                data = data.get('return')
            content = yaml.safe_dump(data, default_flow_style=False, indent=4)

        self.__current_section.append({title: content})
1144467
def generate_top_psms(psms, protcol):
    """"""
    top_ms1_psms = {}
    for psm in psms:
        protacc = psm[protcol]
        precursor_amount = psm[mzidtsvdata.HEADER_PRECURSOR_QUANT]
        if ';' in protacc or precursor_amount == 'NA':
            continue
        precursor_amount = float(precursor_amount)
        psm_seq = psm[mzidtsvdata.HEADER_PEPTIDE]
        try:
            peptide_area = top_ms1_psms[protacc][psm_seq]
        except KeyError:
            try:
                top_ms1_psms[protacc][psm_seq] = precursor_amount
            except KeyError:
                top_ms1_psms[protacc] = {psm_seq: precursor_amount}
        else:
            if precursor_amount > peptide_area:
                top_ms1_psms[protacc][psm_seq] = precursor_amount
    return top_ms1_psms
687025
def get_process_mapping():
    
    output = subprocess.check_output([
        'ps', '-ww', '-o', 'pid=', '-o', 'ppid=', '-o', 'args=',
    ])
    if not isinstance(output, str):
        output = output.decode(sys.stdout.encoding)
    processes = {}
    for line in output.split('\n'):
        try:
            pid, ppid, args = line.strip().split(None, 2)
        except ValueError:
            continue
        processes[pid] = Process(
            args=tuple(shlex.split(args)), pid=pid, ppid=ppid,
        )
    return processes
740632
def ps():
    '''
    
    '''
    containers = get_containers()
    containers = [pretty_container(c) for c in containers]
    print_table(containers, ['name', 'ip', 'ports', 'created', 'image'], sort='name')
185123
def generate_pmlb_summary(local_cache_dir=None):
    
    report_filename = open(os.path.join(local_cache_dir, 'report.csv'), 'wt')
    assert (local_cache_dir!=None)
    try:
        writer = csv.writer(report_filename, delimiter='\t')
        writer.writerow(['Dataset','#instances','#features','#binary_features','#integer_features','#float_features',\
                     'Endpoint_type','#classes','Imbalance_metric'])

        for dataset in dataset_names:
            df=fetch_data(dataset)
            print( "Dataset:", dataset)
            assert 'class' in df.columns, "no class column"
            #removing class column
            print( "SIZE: "+ str(len(df.axes[0]))+ " x " + str(len(df.axes[1])-1))
            feat=count_features_type(df.ix[:, df.columns != 'class'])
            endpoint=determine_endpoint_type(df.ix[:, df.columns == 'class'])
            mse=imbalance_metrics(df['class'].tolist())
            #writer.writerow([file,str(len(df.axes[0])),str(len(df.axes[1])-1),feat[0],feat[1],feat[2],endpoint,mse[0],mse[1],mse[2]])
            writer.writerow([dataset,str(len(df.axes[0])),str(len(df.axes[1])-1),feat[0],feat[1],feat[2],endpoint,int(mse[0]),mse[1]])
    finally:
        report_filename.close()
627005
def pyxwriter(self):
        """"""
        model = self.Model()
        if hasattr(self, 'Parameters'):
            model.parameters = self.Parameters(vars(self))
        else:
            model.parameters = parametertools.Parameters(vars(self))
        if hasattr(self, 'Sequences'):
            model.sequences = self.Sequences(model=model, **vars(self))
        else:
            model.sequences = sequencetools.Sequences(model=model,
                                                      **vars(self))
        return PyxWriter(self, model, self.pyxfilepath)
794464
public void writeDict(PrintWriter fout) throws IOException {
	Iterator it = null;
	int count = 0;

	for (it = dict.keySet().iterator(); it.hasNext(); ) {
	    Integer cpInt = (Integer)it.next();
	    Element elem = (Element)dict.get(cpInt);
	    
	    if (elem.chosen == 1) {
		count++;
	    }
	}
	
	// write the dictionary size
	fout.println(Integer.toString(count));	
	
	for (it = dict.keySet().iterator(); it.hasNext(); ) {    
	
	    Integer cpInt = (Integer)it.next();
	    Element elem = (Element)dict.get(cpInt);
	    
	    if (elem.chosen == 0) {
		continue;
	    }
	    
	    // write the context predicate and its count
	    fout.print(cpInt.toString() + ":" + Integer.toString(elem.count));
	    
	    for (Iterator lbIt = elem.lbCntFidxes.keySet().iterator(); lbIt.hasNext(); ) {
		Integer labelInt = (Integer)lbIt.next();
		CountFIdx cntFIdx = (CountFIdx)elem.lbCntFidxes.get(labelInt);
	
		if (cntFIdx.fidx < 0) {
		    continue;
		}
	
		fout.print(" " + labelInt.toString() + ":" + 
			    Integer.toString(cntFIdx.count) + ":" +
			    Integer.toString(cntFIdx.fidx));		
	    }
	    
	    fout.println();
	}
	
	// write the line ###...
	fout.println(Option.modelSeparator);
    }
676032
def write_client(captures, options):
    
    with open("{}/_client.py".format(options.output_dir), "w") as f:
        f.write(HEADER)
        f.write("from juju.client._definitions import *\n\n")
        clients = ", ".join("_client{}".format(v) for v in captures)
        f.write("from juju.client import " + clients + "\n\n")
        f.write(CLIENT_TABLE.format(clients=",\n    ".join(
            ['"{}": _client{}'.format(v, v) for v in captures])))
        f.write(LOOKUP_FACADE)
        f.write(TYPE_FACTORY)
        for key in sorted([k for k in factories.keys() if "Facade" in k]):
            print(factories[key], file=f)
301112
def _parse_output_records(self, item: IterationRecord) -> Dict[str, Any]:
        """"""
        output_records = {}
        for key, sub_item in item.output_records.items():
            if isinstance(sub_item, dict) or isinstance(sub_item, list):
                output_records[key] = sub_item
            else:
                output_records[key] = sub_item.__dict__

        return output_records
100626
def _write_source_data(self, sources):
        
        for i, source in enumerate(sources):
            self._write_source(source)