예제 #1
0
    def test_Parsing(self):
        bibtex = """

@article{delaRosaTrevin2013,
title = "Xmipp 3.0: An improved software suite for image processing in electron microscopy ",
journal = "Journal of Structural Biology ",
volume = "184",
number = "2",
pages = "321 - 328",
year = "2013",
issn = "1047-8477",
doi = "http://dx.doi.org/10.1016/j.jsb.2013.09.015",
url = "http://www.sciencedirect.com/science/article/pii/S1047847713002566",
author = "J.M. de la Rosa-Trevín and J. Otón and R. Marabini and A. Zaldívar and J. Vargas and J.M. Carazo and C.O.S. Sorzano",
keywords = "Electron microscopy, Single particles analysis, Image processing, Software package "
}

@incollection{Sorzano2013,
title = "Semiautomatic, High-Throughput, High-Resolution Protocol for Three-Dimensional Reconstruction of Single Particles in Electron Microscopy",
booktitle = "Nanoimaging",
year = "2013",
isbn = "978-1-62703-136-3",
volume = "950",
series = "Methods in Molecular Biology",
editor = "Sousa, Alioscka A. and Kruhlak, Michael J.",
doi = "10.1007/978-1-62703-137-0_11",
url = "http://dx.doi.org/10.1007/978-1-62703-137-0_11",
publisher = "Humana Press",
keywords = "Single particle analysis; Electron microscopy; Image processing; 3D reconstruction; Workflows",
author = "Sorzano, CarlosOscar and Rosa Trevín, J.M. and Otón, J. and Vega, J.J. and Cuenca, J. and Zaldívar-Peraza, A. and Gómez-Blanco, J. and Vargas, J. and Quintana, A. and Marabini, Roberto and Carazo, JoséMaría",
pages = "171-193",
}
"""

        prettyDict(utils.parseBibTex(bibtex))
예제 #2
0
def main():
    # Get arguments.
    args = get_parser().parse_args()

    setObj = EMSet(filename=args.setFile)
    firstItem = setObj.getFirstItem()
    root = pwutils.findRootFrom(args.setFile, firstItem.getFileName())
    print("ROOT: ", root)

    if args.output_text:
        with open(args.output, 'w') as f:
            for movie in setObj:
                f.write('%s\n' % movie.getFileName())
    elif args.print:
        for item in setObj:
            print(item.getFileName())
    elif args.copy:
        for item in setObj:
            fn = os.path.join(root, item.getFileName())
            print('Copying %s to %s' % (fn, args.output))
            pwutils.copyFile(fn, args.output)

    elif args.check_dims:
        from pwem.emlib.image import ImageHandler
        ih = ImageHandler()

        counter = {}

        for item in setObj:
            fn = os.path.join(root, item.getFileName())
            dims = ih.getDimensions(fn)
            counter[dims] = 1 if dims not in counter else counter[dims] + 1
            print('%s: %s' % (os.path.basename(fn), dims))

        pwutils.prettyDict(counter)
예제 #3
0
    def exportParticlesStep(self, particlesId):
        """ Create the input file in STAR format as expected by Relion.
        If the input particles comes from Relion, just link the file. 
        """
        imgSet = self.inputParticles.get()
        self._stackType = self.stackType.get()
        self._ih = em.ImageHandler()
        self._stackDict = {}
        particlesPath = self._getPath('Particles')
        pwutils.cleanPath(particlesPath)
        pwutils.makePath(particlesPath)

        alignType = imgSet.getAlignment() if self.useAlignment else em.ALIGN_NONE
        # Create links to binary files and write the relion .star file
        writeSetOfParticles(imgSet, self._getPath("particles.star"),
                            outputDir=self._getExtraPath(),
                            alignType=alignType,
                            postprocessImageRow=self._postprocessImageRow,
                            fillMagnification=True)

        pwutils.prettyDict(self._stackDict)
예제 #4
0
    def test_Parsing(self):
        bibtex = """

@article{delaRosaTrevin2013,
title = "Xmipp 3.0: An improved software suite for image processing in electron microscopy ",
journal = "Journal of Structural Biology ",
volume = "184",
number = "2",
pages = "321 - 328",
year = "2013",
issn = "1047-8477",
doi = "http://dx.doi.org/10.1016/j.jsb.2013.09.015",
url = "http://www.sciencedirect.com/science/article/pii/S1047847713002566",
author = "J.M. de la Rosa-Trevín and J. Otón and R. Marabini and A. Zaldívar and J. Vargas and J.M. Carazo and C.O.S. Sorzano",
keywords = "Electron microscopy, Single particles analysis, Image processing, Software package "
}

@incollection{Sorzano2013,
title = "Semiautomatic, High-Throughput, High-Resolution Protocol for Three-Dimensional Reconstruction of Single Particles in Electron Microscopy",
booktitle = "Nanoimaging",
year = "2013",
isbn = "978-1-62703-136-3",
volume = "950",
series = "Methods in Molecular Biology",
editor = "Sousa, Alioscka A. and Kruhlak, Michael J.",
doi = "10.1007/978-1-62703-137-0_11",
url = "http://dx.doi.org/10.1007/978-1-62703-137-0_11",
publisher = "Humana Press",
keywords = "Single particle analysis; Electron microscopy; Image processing; 3D reconstruction; Workflows",
author = "Sorzano, CarlosOscar and Rosa Trevín, J.M. and Otón, J. and Vega, J.J. and Cuenca, J. and Zaldívar-Peraza, A. and Gómez-Blanco, J. and Vargas, J. and Quintana, A. and Marabini, Roberto and Carazo, JoséMaría",
pages = "171-193",
}
"""        
        f = StringIO()
        f.write(bibtex)
        f.seek(0, 0)
        parser = BibTexParser(f)
        from pyworkflow.utils import prettyDict
        prettyDict(parser.get_entry_dict())
    def exportParticlesStep(self, particlesId):
        """ Create the input file in STAR format as expected by Relion.
        If the input particles comes from Relion, just link the file. 
        """
        imgSet = self.inputParticles.get()
        self._stackType = self.stackType.get()
        self._ih = em.ImageHandler()
        self._stackDict = {}
        particlesPath = self._getPath('Particles')
        pwutils.cleanPath(particlesPath)
        pwutils.makePath(particlesPath)

        alignType = imgSet.getAlignment(
        ) if self.useAlignment else em.ALIGN_NONE
        # Create links to binary files and write the relion .star file
        writeSetOfParticles(imgSet,
                            self._getPath("particles.star"),
                            outputDir=self._getExtraPath(),
                            alignType=alignType,
                            postprocessImageRow=self._postprocessImageRow,
                            fillMagnification=True)

        pwutils.prettyDict(self._stackDict)
예제 #6
0
def checkPlugins():
    """ Discover all plugins and print some info.
    """
    plugins = Domain.getPlugins()
    env = createEnvironment()
    print("Plugins:")
    for k, plugin in plugins.iteritems():
        print("-", plugin.__name__)
        plugin.Plugin.defineBinaries(env)

    print("\nDefined binaries: ")
    print(env.printHelp())

    if args.verbosity > 0:
        print("Objects")
        pwutils.prettyDict(Domain.getObjects())

        print("Protocols")
        pwutils.prettyDict(Domain.getProtocols())

        print("Viewers")
        pwutils.prettyDict(Domain.getViewers())
dataFn = getDataFile(SESSIONS_FILE)

sMan = SessionManager(dataFn)

sessionsSet = sMan.getSessions()
counters = sessionsSet.counters.get()

print("Counters: ")

def cmpKey(key1, key2):
    if key1 == key2:
        return 0
    l1, l2 = len(key1), len(key2)
    if l1 == l2:
        return -1 if key1 < key2 else 1
    return -1 if l1 < l2 else 1

if '--as-params' in sys.argv:
    params = []
    keys = sorted(counters.keys())
    for k in keys:
        v = counters[k]
        params.append({"label": k, "value": v})
    form = {"params": params}
    print(json.dumps(form, indent=4))
else:
    pwutils.prettyDict(counters)


            'cem': 0,
            'fac': 0,
            'sll': 0,
            'dbb': 0,
            'mmk': 0
        }
    }

    wrongGroups = []

    for r in reservations:
        d = stats[r.resource.get()]
        group = r.user.getGroup()
        if r.isNationalFacility():
            d['cem'] += r.getTotalDays()
        else:
            if group not in d:
                wrongGroups.append((group, r.username.get()))
            else:
                d[group] += r.getTotalDays()

    printReservations(reservations)
    print("Reservations: %d" % len(reservations))

    pwutils.prettyDict(stats)

    if wrongGroups:
        print("ERROR: Wrong groups: ")
    for group, username in wrongGroups:
        print("   group: '%s', user: %s" % (group, username))
if len(sys.argv) > 2:
    outputStar = sys.argv[2]
else:
    outputStar = pwutils.removeExt(inputStar) + '_existing.star'

outputMd = md.MetaData()

fnDict = {}
index = None
IMG = 'rlnImageName'
MIC = 'rlnMicrographName'

for row in md.iterRows(inputStar):
    label = IMG if row.hasLabel(IMG) else MIC
    fn = row.getValue(label)

    if '@' in fn:
        index, fn = fn.split('@')

    if fn not in fnDict:
        fnDict[fn] = os.path.exists(fn)

    # Copy the item to the output md if the filename exists
    if fnDict[fn]:
        row.addToMd(outputMd)

print "Writing output to: %s" % outputStar
outputMd.write(outputStar)

pwutils.prettyDict(fnDict)
예제 #10
0
    return ''


n = len(sys.argv)

if n > 4:
    usage("Incorrect number of input parameters")

if n == 1:  # List all plugins
    plugins = Domain.getPlugins()
    print("Plugins:")
    for k, v in iteritems(plugins):
        print("-", k)

    print("Objects")
    pwutils.prettyDict(Domain.getObjects())

    print("Protocols")
    pwutils.prettyDict(Domain.getProtocols())

    print("Viewers")
    pwutils.prettyDict(Domain.getViewers())

elif n == 2:
    if sys.argv[1] in ['-h', '--help', 'help']:
        usage()

    pluginName = sys.argv[1]
    plugin = Domain.getPlugin(pluginName)
    print("Plugin: %s" % pluginName)
    for subName in [