Exemplo n.º 1
0
def run(username, password, host, port):

    full_names = ["Francis Crick",
              "Linda Buck",
              "Charles Darwin",
              "Marie Curie",
              "Alexander Fleming",
              "Rosalind Franklin",
              "Robert Hooke",
              "Jane Goodall",
              "Gregor Mendel",
              "Barbara McClintock",
              "Louis Pasteur",
              "Ada Lovelace",
              "Linus Pauling",
              "Frances Kelsey",
              "Maurice Wilkins",
              "Florence Nightingale",
              "John Sulston",
              "Elizabeth Blackwell",
              "Richard Dawkins",
              "Caroline Dean",
              "Stephen Reicher",
              "Wendy Barclay",
              "Paul Nurse",
              "Jennifer Doudna",
              "Adrian Thomas",
              "Ann Clarke",
              "Oswald Avery",
              "Liz Sockett",
              "Erwin Chargaff",
              "Tracey Rogers",
              "Ronald Fisher",
              "Rachel Carson",
              "William Harvey",
              "Nettie Stevens",
              "Jeffrey Hall",
              "Youyou Tu",
              "Michael Rosbash",
              "Carol Greider",
              "Yoshinori Ohsumi",
              "Rosalyn Yalow"]

    conn = BlitzGateway(username, password, host=host, port=port)
    try:
        conn.connect()
        admin_service = conn.getAdminService()
        for i, full_name in enumerate(full_names):
            username = '******' % (i + 1)
            print username, full_name
            exp = admin_service.lookupExperimenter(username)
            names = full_name.split(" ")
            exp.firstName = rstring(names[0])
            exp.lastName = rstring(names[1])
            admin_service.updateExperimenter(exp)

    except Exception as exc:
            print "Error while renaming users: %s" % str(exc)
    finally:
        conn.close()
Exemplo n.º 2
0
    def testExperimenterListParents(self):
        """Test listParents() for Experimenter in ExperimenterGroup."""

        client, exp = self.new_client_and_user()
        conn = BlitzGateway(client_obj=client)

        userGroupId = conn.getAdminService().getSecurityRoles().userGroupId
        exp = conn.getUser()
        groups = exp.listParents()
        assert len(groups) == 2
        gIds = [g.id for g in groups]
        assert userGroupId in gIds

        # ExperimenterGroup has no parent
        assert len(groups[0].listParents()) == 0
Exemplo n.º 3
0
def runAsScript():

    dataTypes = [rstring('Image')]

    models_path=os.path.join(SCRIPT_PATH, "sample/classifiers/")
    systems=['carver']

    segmentationModel = []
    for file in os.listdir(models_path):
        if file.endswith(".model"):
            segmentationModel.append(str(os.path.join(models_path,file)))

    client = scripts.client('weka_tfmq.py', """Segment a dataset using Random Forest and a known classifier""",

    scripts.String("Data_Type", optional=False, grouping="1",
        description="Pick Images by 'Image' ID or by the ID of their 'Dataset'", values=dataTypes, default="Image"),

    scripts.List("IDs", optional=False, grouping="1.1",
        description="List of Dataset IDs or Image IDs to process.").ofType(rlong(0)),

    scripts.String("Segmentation_model", optional=False, grouping="2",
        description="Select model", values=segmentationModel, default=segmentationModel[0]),

    scripts.String("System", optional=False, grouping="3",
        description="Select the system", values=systems, default=systems[0]),

    scripts.String("Wall_time", grouping="3.1",
        description="Wall time", default='0:30:00'),

    scripts.String("Private_memory", grouping="3.2",
        description="Private memory", default='4GB'),

    scripts.Bool("Big_memory_nodes", grouping="3.2.1",
        description="Big memory nodes", default='False'),

    scripts.String("Nodes", grouping="3.3",
        description="Nodes", default='1'),

    scripts.String("PPN", grouping="3.4",
        description="PPN", default='5'),

    version = "0",
    authors = ["Joaquin Correa", "Data and Analytics services"],
    institutions = ["National Energy Research Scientific Computing Center (NERSC)"],
    contact = "*****@*****.**",
    )

    try:
        session = client.getSession();

        scriptParams = {}
        for key in client.getInputKeys():
            if client.getInput(key):
                scriptParams[key] = client.getInput(key, unwrap=True)

        conn = BlitzGateway(client_obj=client)

        admin = conn.getAdminService()
        uuid = admin.getEventContext().sessionUuid
        weka_segmentation(conn, scriptParams, uuid)

    finally:
        client.closeSession()
# list users with the 'IDs' parameter
#exp_id = script_params["Experimenter"]
experimenters = conn.getObjects("Experimenter")
exp_ids = []

for e in experimenters:
    print e.id, e.firstName, e.lastName
    if e.id > 1:
        exp_ids.append(e.id)

print "list ids", exp_ids

# move users to a single object, in this case public domain

public_group_id = 5
adminService = conn.getAdminService()

for eid in exp_ids:
    adminService.addGroups(ExperimenterI(eid, False),
                           [ExperimenterGroupI(public_group_id, False)])

# Return some value(s).

# Here, we return anything useful the script has produced.
# NB: The Insight and web clients will display the "Message" output.

msg = "Script ran OK"
client.setOutput("Message", rstring(msg))

client.closeSession()
Exemplo n.º 5
0
def runAsScript():

    dataTypes = [rstring('Image')]

    models_path="/project/projectdirs/ngbi/jobs/ij_macros/classifiers"
    systems=['carver', 'sgnworker']

    # modelPath = []
    segmentationModel = []
    for file in os.listdir(models_path):
        if file.endswith(".model"):
            segmentationModel.append(str(os.path.join(models_path,file)))
            # segmentationModel.append(file)

    # Include files metadata information; link to a web application

    # segmentationModel = ['Desulfovibrio RCH1', 'Geobacter', 'Myxococcus Xanthus1', 'Myxococcus Xanthus2']

    client = scripts.client('weka_serial.py', """Segment a dataset using Random Forest and a known classifier""",

    scripts.String("Data_Type", optional=False, grouping="1",
        description="Pick Images by 'Image' ID or by the ID of their 'Dataset'", values=dataTypes, default="Image"),

    scripts.List("IDs", optional=False, grouping="1.1",
        description="List of Dataset IDs or Image IDs to process.").ofType(rlong(0)),

    scripts.String("Segmentation_model", optional=False, grouping="2",
        description="Select model", values=segmentationModel, default=segmentationModel[0]),

    scripts.String("System", optional=False, grouping="3",
        description="Select the system", values=systems, default=systems[0]),

    scripts.String("Wall_time", grouping="3.1",
        description="Wall time", default='0:30:00'),

    scripts.String("Private_memory", grouping="3.2",
        description="Private memory", default='4GB'),

    scripts.Bool("Big_memory_nodes", grouping="3.2.1",
        description="Big memory nodes", default='False'),

    scripts.String("Nodes", grouping="3.3",
        description="Nodes", default='1'),

    scripts.String("PPN", grouping="3.4",
        description="PPN", default='5'),

    version = "0",
    authors = ["Joaquin Correa", "OSP Team"],
    institutions = ["NERSC"],
    contact = "*****@*****.**",
    )

    try:
        session = client.getSession();





        # print("session key: %s" % (session)

        # process the list of args above.
        scriptParams = {}
        for key in client.getInputKeys():
            if client.getInput(key):
                scriptParams[key] = client.getInput(key, unwrap=True)

        print scriptParams

        print("key: %s" % (key))
        # print("session key: %s" % (session))

        # wrap client to use the Blitz Gateway
        conn = BlitzGateway(client_obj=client)

        admin = conn.getAdminService()
        uuid = admin.getEventContext().sessionUuid
        # uuid = uuid.split(":")[1]


        print(uuid)

        # print("key: %s" % (key))

        # sizeZ, sizeC, sizeT, sizeX, sizeY, dataset = newFilteredImage(conn, scriptParams)
        # newFilteredImage(conn, scriptParams)

        # sloopy("/global/project/projectdirs/ngbi/omero-0.7/OMERO.server/lib/scripts/omero/tmp/WT_7B_duct2.mrc")
        weka_segmentation(conn, scriptParams, uuid)

        # print sizeZ, sizeC, sizeT, sizeX, sizeY, dataset

        # Return message, new image and new dataset (if applicable) to the client
        # client.setOutput("Message", rstring(message))
        # if len(images) == 1:
        #     client.setOutput("Image", robject(images[0]._obj))
        # if dataset is not None:
        #     client.setOutput("New Dataset", robject(dataset._obj))

    finally:
        client.closeSession()