retrieve a sample of the file
430360
def get_file_sample(self, numLines=10):
        
        res = ''
        try:
            with open(self.fullname, 'r') as f:
                for line_num, line in enumerate(f):
                    res += str(line_num).zfill(5) + ' ' + line 
                    if line_num >= numLines-1:
                        break
            return res
        except Exception as ex:
            print('cant get_file_sample in "', self.fullname, '":', str(ex))
            return res
346805
def from_sample(sample):
    
    upload_config = sample.get("upload")
    if upload_config:
        approach = _approaches[upload_config.get("method", "filesystem")]
        for finfo in _get_files(sample):
            approach.update_file(finfo, sample, upload_config)
    return [[sample]]
540021
def get_sample_window(self, type_tag, size=10):
        

        # Convert size to MB
        size = size * 1024 * 1024

        # Grab all the samples of type=type_tag, sort by import_time (newest to oldest)
        cursor = self.database[self.sample_collection].find({'type_tag': type_tag},
            {'md5': 1,'length': 1}).sort('import_time',pymongo.DESCENDING)
        total_size = 0
        md5_list = []
        for item in cursor:
            if total_size > size:
                return md5_list
            md5_list.append(item['md5'])
            total_size += item['length']

        # If you get this far you don't have 'size' amount of data
        # so just return what you've got
        return md5_list
774762
@Override
  public final void sample()
  {
    long count = _count.get();
    long lastCount = _lastCount.getAndSet(count);
    
    _value = count - lastCount;
  }
973836
def get_file_stream(self):
        
        if self.file_stream:
            self.file_stream.seek(0)
            return self.file_stream
        elif os.path.isfile(self.file_path):
            return open(self.file_path, 'rb')
        else:
            raise ValueError("invalid file {}".format(self.file_path))
736875
def get_in_samples(samples, fn):
    
    for sample in samples:
        sample = to_single_data(sample)
        if fn(sample, None):
            return fn(sample)
    return None
1144238
def read_examples(input_file):
    """"""
    examples = []
    unique_id = 0
    with open(input_file, "r", encoding='utf-8') as reader:
        while True:
            line = reader.readline()
            if not line:
                break
            line = line.strip()
            text_a = None
            text_b = None
            m = re.match(r"^(.*) \|\|\| (.*)$", line)
            if m is None:
                text_a = line
            else:
                text_a = m.group(1)
                text_b = m.group(2)
            examples.append(
                InputExample(unique_id=unique_id, text_a=text_a, text_b=text_b))
            unique_id += 1
    return examples
518954
def Read(self, length):
    """"""
    if not self.IsFile():
      raise IOError("%s is not a file." % self.pathspec.last.path)

    available = min(self.size - self.offset, length)
    if available > 0:
      # This raises a RuntimeError in some situations.
      try:
        data = self.fd.read_random(self.offset, available,
                                   self.pathspec.last.ntfs_type,
                                   self.pathspec.last.ntfs_id)
      except RuntimeError as e:
        raise IOError(e)

      self.offset += len(data)

      return data
    return b""
1285756
def get(self, name):
        
        # load the file by path name
        with open(os.path.join(self.parent,
                               name.strip()), 'rb') as f:
            data = f.read()
        return data
142115
def getabsfile(object):
    """"""
    return os.path.normcase(
        os.path.abspath(getsourcefile(object) or getfile(object)))
758439
def _get_files(sample):
    
    analysis = sample.get("analysis")
    if analysis.lower() in ["variant", "snp calling", "variant2", "standard"]:
        return _get_files_variantcall(sample)
    elif analysis.lower() in ["rna-seq", "fastrna-seq"]:
        return _get_files_rnaseq(sample)
    elif analysis.lower() in ["smallrna-seq"]:
        return _get_files_srnaseq(sample)
    elif analysis.lower() in ["chip-seq"]:
        return _get_files_chipseq(sample)
    elif analysis.lower() in ["scrna-seq"]:
        return _get_files_scrnaseq(sample)
    else:
        return []
112490
def sample_string(self, individual=-1):
        """"""
        base = str(self)
        extra = self.get_sample_info(individual=individual)
        extra = [':'.join([str(j) for j in i]) for i in zip(*extra.values())]
        return '\t'.join([base, '\t'.join(extra)])
1349141
def fetch(self):
        
        params = values.of({})

        payload = self._version.fetch(
            'GET',
            self._uri,
            params=params,
        )

        return SampleInstance(
            self._version,
            payload,
            assistant_sid=self._solution['assistant_sid'],
            task_sid=self._solution['task_sid'],
            sid=self._solution['sid'],
        )
175360
def file_contents(file_name):
    """"""
    curr_dir = os.path.abspath(os.path.dirname(__file__))
    with open(os.path.join(curr_dir, file_name)) as the_file:
        contents = the_file.read()
    return contents
97255
def get_sample_frame(self):
        """"""
        for frame in self.frames:
            return frame.open()

        for res in self.results.values():
            return res.open()

        return None
237955
function getFile (str) {
  var ret = null
  var match = /[0-9]+,[0-9]+,.*/.test(str)
  if (!match) {
    return null
  }
  var a = str.split(',')
  if (a && a[2]) {
    ret = a[2]
    return ret
  } else {
    return null
  }
  if (isNaN(ret)) {
    return null
  }
  return ret
}
1308488
def read(filename):
    """"""
    path = join(here, filename)
    with open(path, "r") as fin:
        return fin.read().strip()