Returns array of citation locations (index) in manuscript

     contents = File.read('./spec/testfiles/test.txt')
     PaperCitations.index_cite(contents, 'Peters et al. 2007')
     # => [219, 500]
438606
def index_of_cite(cite)
      cite_parts = cite.split
      author_s = cite_parts.take(cite_parts.size-1).join(' ')
      year_s = cite_parts.last
      @contents.enum_for(:scan, /(#{author_s}#{possessive}?#{year(year_s)})/
                        ).map { Regexp.last_match.begin(0) }
    end
513931
def getIndexStripUrl(self, index):
        """"""
        chapter, num = index.split('-')
        return self.stripUrl % (chapter, chapter, num)
906844
def files(self):
        
        files_description = [
            [ self.project_name,
              self.project_name + '.tex',
              'LaTeXBookFileTemplate'
            ],
            [ self.project_name,
              'references.bib',
              'BibTeXFileTemplate'
            ],
            [ self.project_name,
              'Makefile',
              'LaTeXMakefileFileTemplate'
            ],
        ]
        return files_description
737519
def reference_index(self):
        """"""
        if self._db_location:
            ref_indices = glob.glob(os.path.join(self._db_location, "*", self._REF_INDEX))
            if ref_indices:
                return ref_indices[0]
660848
def _find_read_splits(in_file, split_size):
    
    num_lines = total_reads_from_grabix(in_file) * 4
    assert num_lines and num_lines > 0, "Did not find grabix index reads: %s %s" % (in_file, num_lines)
    split_lines = split_size * 4
    chunks = []
    last = 1
    for chunki in range(num_lines // split_lines + min(1, num_lines % split_lines)):
        new = last + split_lines - 1
        chunks.append((last, min(new, num_lines)))
        last = new + 1
    return ["%s-%s" % (s, e) for s, e in chunks]
370363
def get_bibtex(self):
        
        if self.aggregationType != 'Journal':
            raise ValueError('Only Journal articles supported.')
        # Item key
        year = self.coverDate[0:4]
        first = self.title.split()[0].title()
        last = self.title.split()[-1].title()
        key = ''.join([self.authors[0].surname, year, first, last])
        # Authors
        authors = ' and '.join(["{} {}".format(a.given_name, a.surname)
                                for a in self.authors])
        # Pages
        if self.pageRange:
            pages = self.pageRange
        elif self.startingPage:
            pages = '{}-{}'.format(self.startingPage, self.endingPage)
        else:
            pages = '-'
        # All information
        bib = "@article{{{key},\n  author = {{{auth}}},\n  title = "\
              "{{{{{title}}}}},\n  journal = {{{jour}}},\n  year = "\
              "{{{year}}},\n  volume = {{{vol}}},\n  number = {{{number}}},"\
              "\n  pages = {{{pages}}}".format(
                key=key, auth=authors, title=self.title, year=year,
                jour=self.publicationName, vol=self.volume,
                number=self.issueIdentifier, pages=pages)
        # DOI
        if self.doi:
            bib += ",\n  doi = {{{}}}".format(self.doi)
        bib += "}"
        return bib
63039
def citation(self):
        
        path = find_dataset_path(
            self.name, data_home=self.data_home, fname="meta.json", raises=False
        )
        if path is None:
            return None

        with open(path, 'r') as f:
            return f.read()
749947
def _index_mountpoints(self):
        """"""

        # find all mountponits
        self.mountpoints = {}
        # noinspection PyBroadException
        try:
            result = _util.check_output_(['mount'])
            for line in result.splitlines():
                m = re.match(r'(.+) on (.+) type (.+) \((.+)\)', line)
                if m:
                    self.mountpoints[m.group(2)] = (m.group(1), m.group(3), m.group(4))
        except Exception:
            pass
1176900
def journals(self):
        
        try:
            target = self._item_path
            json_data = self._redmine.get(target % str(self.id),
                                          parms={'include': 'journals'})
            data = self._redmine.unwrap_json(None, json_data)
            journals = [Journal(redmine=self._redmine,
                                data=journal,
                                type='issue_journal')
                        for journal in data['issue']['journals']]

            return journals

        except Exception:
            return []
292838
def summarizePosition(self, index):
        
        countAtPosition = Counter()
        excludedCount = 0

        for read in self:
            try:
                countAtPosition[read.sequence[index]] += 1
            except IndexError:
                excludedCount += 1

        return {
            'excludedCount': excludedCount,
            'countAtPosition': countAtPosition
        }
1342428
def get_indexes_from_base(self):
        
        if self.is_indexed:
            return np.copy(self.order[i])
        if self.data.base is None:
            i = 0
        else:
            i = self.get_raw_index(0)
        return np.arange(i, i + len(self), dtype=np.uint32)
1348655
def get_completerlib():
    
    #-----------------------------------------------------------------------------
    #  Copyright (C) 2010-2011 The IPython Development Team.
    #
    #  Distributed under the terms of the BSD License.
    #
    #  The full license is in the file COPYING.txt, distributed with this software.
    #-----------------------------------------------------------------------------

    #-----------------------------------------------------------------------------
    # Imports
    #-----------------------------------------------------------------------------
    #from __future__ import print_function

    import inspect
    import os
    #import re
    #import sys

    try:
        # Python >= 3.3
        from importlib.machinery import all_suffixes
        _suffixes = all_suffixes()
    except ImportError:
        from imp import get_suffixes
        _suffixes = [ s[0] for s in get_suffixes() ]

    # Third-party imports
    from time import time
    from zipimport import zipimporter

    TIMEOUT_STORAGE = 2

    TIMEOUT_GIVEUP = 20

    # Regular expression for the python import statement
    import_re = re.compile(r'(?P<name>[a-zA-Z_][a-zA-Z0-9_]*?)'
                           r'(?P<package>[/\\]__init__)?'
                           r'(?P<suffix>%s)$' %
                           r'|'.join(re.escape(s) for s in _suffixes))

    # RE for the ipython %run command (python + ipython scripts)
    magic_run_re = re.compile(r'.*(\.ipy|\.ipynb|\.py[w]?)$')

    def module_list(path):
        """
        Return the list containing the names of the modules available in the given
        folder.
        """
        # sys.path has the cwd as an empty string, but isdir/listdir need it as '.'
        if path == '':
            path = '.'

        # A few local constants to be used in loops below
        pjoin = os.path.join

        if os.path.isdir(path):
            # Build a list of all files in the directory and all files
            # in its subdirectories. For performance reasons, do not
            # recurse more than one level into subdirectories.
            files = []
            for root, dirs, nondirs in os.walk(path):
                subdir = root[len(path)+1:]
                if subdir:
                    files.extend(pjoin(subdir, f) for f in nondirs)
                    dirs[:] = [] # Do not recurse into additional subdirectories.
                else:
                    files.extend(nondirs)

        else:
            try:
                files = list(zipimporter(path)._files.keys())
            except:
                files = []

        # Build a list of modules which match the import_re regex.
        modules = []
        for f in files:
            m = import_re.match(f)
            if m:
                modules.append(m.group('name'))
        return list(set(modules))


    def get_root_modules():
        """
        Returns a list containing the names of all the modules available in the
        folders of the pythonpath.

        ip.db['rootmodules_cache'] maps sys.path entries to list of modules.
        """
        #ip = get_ipython()
        #rootmodules_cache = ip.db.get('rootmodules_cache', {})
        rootmodules_cache = {}
        rootmodules = list(sys.builtin_module_names)
        start_time = time()
        #store = False
        for path in sys.path:
            try:
                modules = rootmodules_cache[path]
            except KeyError:
                modules = module_list(path)
                try:
                    modules.remove('__init__')
                except ValueError:
                    pass
                if path not in ('', '.'): # cwd modules should not be cached
                    rootmodules_cache[path] = modules
                if time() - start_time > TIMEOUT_STORAGE and not store:
                    #store = True
                    #print("\nCaching the list of root modules, please wait!")
                    #print("(This will only be done once - type '%rehashx' to "
                          #"reset cache!)\n")
                    sys.stdout.flush()
                if time() - start_time > TIMEOUT_GIVEUP:
                    print("This is taking too long, we give up.\n")
                    return []
            rootmodules.extend(modules)
        #if store:
            #ip.db['rootmodules_cache'] = rootmodules_cache
        rootmodules = list(set(rootmodules))
        return rootmodules


    def is_importable(module, attr, only_modules):
        if only_modules:
            return inspect.ismodule(getattr(module, attr))
        else:
            return not(attr[:2] == '__' and attr[-2:] == '__')


    def try_import(mod, only_modules=False):
        try:
            m = __import__(mod)
        except:
            return []
        mods = mod.split('.')
        for module in mods[1:]:
            m = getattr(m, module)

        m_is_init = hasattr(m, '__file__') and '__init__' in m.__file__

        completions = []
        if (not hasattr(m, '__file__')) or (not only_modules) or m_is_init:
            completions.extend( [attr for attr in dir(m) if
                                 is_importable(m, attr, only_modules)])

        completions.extend(getattr(m, '__all__', []))
        if m_is_init:
            completions.extend(module_list(os.path.dirname(m.__file__)))
        completions = set(completions)
        if '__init__' in completions:
            completions.remove('__init__')
        return list(completions)


    def module_completion(line):
        """
        Returns a list containing the completion possibilities for an import line.

        The line looks like this :
        'import xml.d'
        'from xml.dom import'
        """

        words = line.split(' ')
        nwords = len(words)

        # from whatever <tab> -> 'import '
        if nwords == 3 and words[0] == 'from':
            return ['import ']

        # 'from xy<tab>' or 'import xy<tab>'
        if nwords < 3 and (words[0] in ['import','from']) :
            if nwords == 1:
                return get_root_modules()
            mod = words[1].split('.')
            if len(mod) < 2:
                return get_root_modules()
            completion_list = try_import('.'.join(mod[:-1]), True)
            return ['.'.join(mod[:-1] + [el]) for el in completion_list]

        # 'from xyz import abc<tab>'
        if nwords >= 3 and words[0] == 'from':
            mod = words[1]
            return try_import(mod)

    return module_completion, module_list
1050966
function getSeedsAtLocation(location) {
  // load the file as JSON
  const result = require(location);

  // Ensure the output is an array
  if (Array.isArray(result)) {
    return _.forEach(result, unmarshalBuffer);
  } else {
    return [ unmarshalBuffer(result) ];
  }
}
496578
def txt_read_in(self):
        

        # read in
        data = ascii.read(self.WORKING_DIRECTORY + '/' + self.file_name)

        # find number of distinct x and y points.
        num_x_pts = len(np.unique(data[self.x_column_label]))
        num_y_pts = len(np.unique(data[self.y_column_label]))

        # create 2D arrays of x,y,z
        self.xvals = np.reshape(np.asarray(data[self.x_column_label]), (num_y_pts, num_x_pts))
        self.yvals = np.reshape(np.asarray(data[self.y_column_label]), (num_y_pts, num_x_pts))
        self.zvals = np.reshape(np.asarray(data[self.z_column_label]), (num_y_pts, num_x_pts))

        return
202878
def load_matches(self):
        
        if not self.exists():
            return []

        matches = []
        with open(self.location(), 'r') as f:
            for line in f.readlines():
                match_obj = json.loads(line.strip("\n"))
                if match_obj['processed']:
                    continue

                matches.append(match_obj)

        return matches
946293
def __get_ra_index_indices(self):
        
        fragment_indices = []
        for idx, cumlen in enumerate(self._cumulative_lengths):
            cumlen_prev = self._cumulative_lengths[idx - 1] if idx > 0 else 0
            fragment_indices.append([np.argwhere(
                np.logical_and(self.ra_indices >= cumlen_prev, self.ra_indices < cumlen)
            )])
        return fragment_indices
637152
def get_reference_section_title_patterns():
    
    patterns = []
    titles = [u'references',
              u'references.',
              u'r\u00C9f\u00E9rences',
              u'r\u00C9f\u00C9rences',
              u'reference',
              u'refs',
              u'r\u00E9f\u00E9rence',
              u'r\u00C9f\u00C9rence',
              u'r\xb4ef\xb4erences',
              u'r\u00E9fs',
              u'r\u00C9fs',
              u'bibliography',
              u'bibliographie',
              u'citations',
              u'literaturverzeichnis']
    sect_marker = u'^\s*([\[\-\{\(])?\s*' \
                  u'((\w|\d){1,5}([\.\-\,](\w|\d){1,5})?\s*' \
                  u'[\.\-\}\)\]]\s*)?' \
                  u'(?P<title>'
    sect_marker1 = u'^(\d){1,3}\s*(?P<title>'
    line_end = r'(\s*s\s*e\s*c\s*t\s*i\s*o\s*n\s*)?)([\)\}\]])?' \
        r'($|\s*[\[\{\(\<]\s*[1a-z]\s*[\}\)\>\]]|\:$)'

    for t in titles:
        t_ptn = re.compile(
            sect_marker +
            _create_regex_pattern_add_optional_spaces_to_word_characters(t) +
            line_end, re.I | re.UNICODE)
        patterns.append(t_ptn)
        # allow e.g.  'N References' to be found where N is an integer
        t_ptn = re.compile(
            sect_marker1 +
            _create_regex_pattern_add_optional_spaces_to_word_characters(t) +
            line_end, re.I | re.UNICODE)
        patterns.append(t_ptn)

    return patterns