Beispiel #1
0
  def fromFile(cls,strfile,fretfile=None):
    'Load stretching data and corresponding fret data from files'
    basename,ext=fileIO.splitext(strfile)
    if not ext:
      strfile = fileIO.add_pull_ext(basename)
    pull = TrapData.fromFile(strfile)
    metadata = {}

    # check if base + .fret exists if not specified already
    # and use it, or else load/don't load fretfile
    fretfileFromBase = fileIO.add_fret_ext(basename)
    if not fretfile and path.exists(fretfileFromBase):
      fretfile = fretfileFromBase
    elif fretfile and not path.exists(fretfile):
      raise ExperimentError("Fret file {0} not found".format(fretfile))
    fret = FretData.fromFile(fretfile) if fretfile else None

    newPull = cls(pull, fret, **metadata)
    newPull.filename = basename

    try:
      newPull.info = fileIO.parseFilename(basename)
    except:
      logger.warning('Problem parsing filename %s' % basename)

    return newPull
Beispiel #2
0
 def filenameMatchesType(cls, filename):
   assert isinstance(filename, str)
   finfo = fileIO.parseFilename(filename)
   if not finfo:
     return False
   for attr in finfo._fields:
     val = getattr(finfo, attr)
     if attr not in cls.FILENAME_SYNTAX and val:
       return False
   return True
Beispiel #3
0
 def filenameMatchesType(cls, filename):
     assert isinstance(filename, str)
     finfo = fileIO.parseFilename(filename)
     if not finfo:
         return False
     for attr in finfo._fields:
         val = getattr(finfo, attr)
         if attr not in cls.FILENAME_SYNTAX and val:
             return False
     return True