コード例 #1
0
ファイル: utils.py プロジェクト: I2PC/scipion
def joinBlocks(inputMd, blockPrefix=None):
    mdImages = MetaData()
    mdAll = MetaData()
    mdBlocks = getBlocksInMetaDataFile(inputMd)
    
    for mdBlock in mdBlocks:
        if blockPrefix is not None:
            if mdBlock.startswith(blockPrefix):
                mdImages.read(mdBlock + "@" + inputMd)
                mdAll.unionAll(mdImages)
        else:
            mdImages.read(mdBlock + "@" + inputMd)
            mdAll.unionAll(mdImages)
    return mdAll
コード例 #2
0
ファイル: utils.py プロジェクト: josegutab/scipion
def getFirstRow(filename):
    """ Create a MetaData but only read the first row.
    This method should be used for validations of labels
    or metadata size, but the full metadata is not needed.
    """
    md = MetaData()
    md.read(filename, 1)
    if md.getParsedLines():
        row = Row()
        row.readFromMd(md, md.firstObject())
    else:
        row = None
    
    return row
コード例 #3
0
def iterRows(md, sortByLabel=None):
    """ Iterate over the rows of the given metadata.
    Params:
        md: a MetaData object or a filename (MetaData will be read)
        sortByLabel: a label to sort the metadata before iterate.
    """
    # If md is string, take as filename and create the metadata

    if isinstance(md, basestring):
        md = MetaData(md)

    if sortByLabel is not None:
        md.sort(sortByLabel)

    row = Row()
    
    for objId in md:
        row.readFromMd(md, objId)
        yield row
コード例 #4
0
ファイル: utils.py プロジェクト: I2PC/scipion
def iterRows(md, sortByLabel=None):
    """ Iterate over the rows of the given metadata.
    Params:
        md: a MetaData object or a filename (MetaData will be read)
        sortByLabel: a label to sort the metadata before iterate.
    """
    # If md is string, take as filename and create the metadata

    if isinstance(md, basestring):
        md = MetaData(md)

    if sortByLabel is not None:
        md.sort(sortByLabel)

    row = Row()
    
    for objId in md:
        row.readFromMd(md, objId)
        yield row
コード例 #5
0
ファイル: utils.py プロジェクト: I2PC/scipion
def getFirstRow(mdOrFn):
    """ Return the first object of a metadata.
    Params:
        mdOrFn: you can pass a metadata or a filename as argument.
    """

    if isinstance(mdOrFn, basestring):
        md = MetaData()
        md.read(mdOrFn, 1)
    else: # mdOrFn is MetaData
        md = mdOrFn
        
    if md.getParsedLines():
        row = Row()
        row.readFromMd(md, md.firstObject())
    else:
        row = None
    
    return row
コード例 #6
0
def getFirstRow(mdOrFn):
    """ Return the first object of a metadata.
    Params:
        mdOrFn: you can pass a metadata or a filename as argument.
    """

    if isinstance(mdOrFn, basestring):
        md = MetaData()
        md.read(mdOrFn, 1)
    else: # mdOrFn is MetaData
        md = mdOrFn
        
    if md.getParsedLines():
        row = Row()
        row.readFromMd(md, md.firstObject())
    else:
        row = None
    
    return row
コード例 #7
0
def getSize(filename):
    """ Return the metadata size without parsing entirely. """
    md = MetaData()
    md.read(filename, 1)
    return md.getParsedLines()
コード例 #8
0
ファイル: utils.py プロジェクト: I2PC/scipion
def getSize(filename):
    """ Return the metadata size without parsing entirely. """
    md = MetaData()
    md.read(filename, 1)
    return md.getParsedLines()