Read reactions from non-organized folder
433372
def organize(**kwargs):
    """"""

    # do argument wrangling  before turning it into an obect
    # since namedtuples are immutable
    if len(kwargs['adsorbates']) == 0:
        print("""Warning: no adsorbates specified,
        can't pick up reaction reaction energies.""")
        print("         Enter adsorbates like so --adsorbates CO,O,CO2")
        print("         [Comma-separated list without spaces.]")
    kwargs['adsorbates'] = list(map(
        lambda x: (''.join(sorted(string2symbols(x)))),
        kwargs['adsorbates'].split(','),
    ))
    if kwargs['energy_corrections']:
        e_c_dict = {}
        for e_c in kwargs['energy_corrections'].split(','):
            key, value = e_c.split('=')
            e_c_dict.update({key: float(value)})
        kwargs['energy_corrections'] = e_c_dict

    options = collections.namedtuple(
        'options',
        kwargs.keys()
    )(**kwargs)
    _organize.main(options=options)
958010
def read_folder(folder):
    
    hwr_objects = []
    for filepath in natsort.natsorted(glob.glob("%s/*.inkml" % folder)):
        tmp = inkml.read(filepath)
        for hwr in tmp.to_single_symbol_list():
            hwr_objects.append(hwr)
    logging.info("Done reading formulas")
    save_raw_pickle(hwr_objects)
    return hwr_objects
438198
def run(itf):
    

    if not itf:
        return 1

    # access user input
    options = SplitInput(itf)

    # read input
    inputpath = os.path.abspath(options.inputpath)
    print(" Reading input file ...")
    molecules = csv_interface.read_csv(inputpath, options)
    if not molecules:
        print("\n '{flag}' was unable to be parsed\n".format(flag=os.path.basename(options.inputpath)))
        sys.exit(1)

    # determine the sort order & ensemble_size
    #sort_order = classification.get_sort_order(molecules)
    sort_order = 'asc'
    ensemble_size = options.ensemble_size

    # loop over all ensembles
    # temp 2/3/15 append to auc_list ef_list & write it out for later histogram construction
    auc_list = []
    ef_list = []
    for size in [x + 1 for x in range(ensemble_size)]:
        auc, ef = optimizor(molecules, sort_order, size, options)
        auc_list += auc
        ef_list += ef
    # temp 2/9/15 write auc_list & ef_list out to files for subsequent post-processing
    f = open('auc_histogram.csv', 'w')
    for value in auc_list:
        f.write('%f\n' % value)
        #f.write('%f, %s\n' % (value[0], value[1]))
    f.close()
    f = open('ef_histogram.csv', 'w')
    for value in ef_list:
        f.write('%f\n' % value)
    f.close()
94691
def get_actions_from_items(self, items):
        """"""
        fromcursor_act = create_action(self, text=_('Go to cursor position'),
                                       icon=ima.icon('fromcursor'),
                                       triggered=self.go_to_cursor_position)
        fullpath_act = create_action(self, text=_('Show absolute path'),
                                     toggled=self.toggle_fullpath_mode)
        fullpath_act.setChecked(self.show_fullpath)
        allfiles_act = create_action(self, text=_('Show all files'),
                                     toggled=self.toggle_show_all_files)
        allfiles_act.setChecked(self.show_all_files)
        comment_act = create_action(self, text=_('Show special comments'),
                                    toggled=self.toggle_show_comments)
        comment_act.setChecked(self.show_comments)
        group_cells_act = create_action(self, text=_('Group code cells'),
                                        toggled=self.toggle_group_cells)
        group_cells_act.setChecked(self.group_cells)
        sort_files_alphabetically_act = create_action(
            self, text=_('Sort files alphabetically'),
            toggled=self.toggle_sort_files_alphabetically)
        sort_files_alphabetically_act.setChecked(
            self.sort_files_alphabetically)
        actions = [fullpath_act, allfiles_act, group_cells_act, comment_act,
                   sort_files_alphabetically_act, fromcursor_act]
        return actions
821532
def run(self):
        """"""

        # Create dictonary of signatures
        database_signatures = {}
        for entry in self._model.reactions:
            signature = reaction_signature(
                entry.equation, direction=self._args.compare_direction,
                stoichiometry=self._args.compare_stoichiometry)
            database_signatures.setdefault(signature, set()).add(
                (entry.id, entry.equation, entry.filemark))

        for reaction_set in itervalues(database_signatures):
            if len(reaction_set) > 1:
                print('Found {} duplicate reactions:'.format(
                    len(reaction_set)))
                for reaction, equation, filemark in reaction_set:
                    result = ' - {}: {}'.format(reaction, equation)
                    if filemark is not None:
                        result += ' (found in {})'.format(filemark)
                    print(result)
1340237
def read_structure(self, cls=Structure):
        """"""
        if self.ngroups != 1:
            raise NotImplementedError("In file %s: ngroups != 1" % self.path)

        return structure_from_ncdata(self, cls=cls)
1275715
def inspect(self):
        """"""
        results = {}
        for fname in dir(self):
            if not fname.startswith('_'):
                value = getattr(self, fname)
                if isinstance(value, collections.Callable):
                    continue
                results[fname] = value
        return results
293182
def read(self, filehandle):
        """"""
        return self.__import(json.load(filehandle, **self.kwargs))
1064280
def _read_sections(ifile):
        """"""
        if os.path.exists(ifile):
            return read_sections(ifile, exclude_ungrouped=True, prt=None)
470790
def _validate_folder(self, folder=None):
        ''' 
        '''
        from expfactory.experiment import load_experiment

        if folder is None:
            folder=os.path.abspath(os.getcwd())

        config = load_experiment(folder, return_path=True)

        if not config:
            return notvalid("%s is not an experiment." %(folder))

        return self._validate_config(folder)
990429
async def listreactions(self, ctx):
        """"""
        data = self.config.get(ctx.message.server.id, {})
        if not data:
            await self.bot.responses.failure(message="There are no reactions on this server.")
            return
        try:
            pager = Pages(self.bot, message=ctx.message, entries=list(data.keys()))
            pager.embed.colour = 0x738bd7  # blurple
            pager.embed.set_author(name=ctx.message.server.name + " Reactions", icon_url=ctx.message.server.icon_url)
            await pager.paginate()

        except Exception as e:
            await self.bot.say(e)
1345435
def dir(cls, label, children):
        """"""
        return FSEntry(label=label, children=children, type=u"Directory", use=None)
864705
public static List<IReaction> getAllReactions(IChemFile file) {
        List<IReaction> reactonList = new ArrayList<IReaction>();
        List<IChemModel> chemModel = getAllChemModels(file);
        for (int f = 0; f < chemModel.size(); f++) {
            for (IReaction reaction : chemModel.get(f).getReactionSet().reactions()) {
                reactonList.add(reaction);
            }
        }
        return reactonList;
    }
61709
def read_actions():
    """"""
    while True:
        key = get_key()

        # Handle arrows, j/k (qwerty), and n/e (colemak)
        if key in (const.KEY_UP, const.KEY_CTRL_N, 'k', 'e'):
            yield const.ACTION_PREVIOUS
        elif key in (const.KEY_DOWN, const.KEY_CTRL_P, 'j', 'n'):
            yield const.ACTION_NEXT
        elif key in (const.KEY_CTRL_C, 'q'):
            yield const.ACTION_ABORT
        elif key in ('\n', '\r'):
            yield const.ACTION_SELECT
1311742
def get_reactions(self):
        
        return github.PaginatedList.PaginatedList(
            github.Reaction.Reaction,
            self._requester,
            self.url + "/reactions",
            None,
            headers={'Accept': Consts.mediaTypeReactionsPreview}
        )
944735
function(dir) {
      var results = [];

      var list = fs.readdirSync(dir);

      list.forEach(function(file) {
        // Check for every given pattern, regardless of whether it is an array or a string
        var matchesSomeExclude = [].concat(options.exclude).some(function(regexp) {
          return file.match(regexp) != null;
        });

        if(!matchesSomeExclude) {
          var matchesSomePattern = [].concat(options.match).some(function(regexp) {
            return file.match(regexp) != null;
          });

          file = path.resolve(dir, file);
          var stat = fs.statSync(file);

          if (stat && stat.isDirectory()) {
            if(matchesSomePattern) {
              results = results.concat(file);
            }
            results = results.concat(walk(file));
          }
        }
      });

      return results;
    }
1302753
def _read_from_folder(self, dirname):
        
        templates = _par_read(dirname=dirname, compressed=False)
        t_files = glob.glob(dirname + os.sep + '*.ms')
        tribe_cat_file = glob.glob(os.path.join(dirname, "tribe_cat.*"))
        if len(tribe_cat_file) != 0:
            tribe_cat = read_events(tribe_cat_file[0])
        else:
            tribe_cat = Catalog()
        previous_template_names = [t.name for t in self.templates]
        for template in templates:
            if template.name in previous_template_names:
                # Don't read in for templates that we already have.
                continue
            for event in tribe_cat:
                for comment in event.comments:
                    if comment.text == 'eqcorrscan_template_' + template.name:
                        template.event = event
            t_file = [t for t in t_files
                      if t.split(os.sep)[-1] == template.name + '.ms']
            if len(t_file) == 0:
                print('No waveform for template: ' + template.name)
                templates.remove(template)
                continue
            elif len(t_file) > 1:
                print('Multiple waveforms found, using: ' + t_file[0])
            template.st = read(t_file[0])
        self.templates.extend(templates)
        return