gbsc_dnanexus.utils¶
Contains useful tools for working with DNAnexus. You should have the environment variable DX_SECURITY_CONTEXT set (http://autodoc.dnanexus.com/bindings/python/current/dxpy.html?highlight=token). You can set this variable as follows un Unix platforms:
export DX_SECURITY_CONTEXT="{"auth_token_type": "Bearer", "auth_token": "your_token"}"
-
exception
gbsc_dnanexus.utils.DxApiKeyNotFound[source]¶ Bases:
ExceptionRaised when the environment variable DX_SECURITY_CONTEXT isn’t set.
-
gbsc_dnanexus.utils.get_dx_username(strip_prefix=False)[source]¶ Returns the DNAnexus username of the currently logged-in user (i.e. user-nathankw).
Parameters: strip_prefix – bool. True indicates to remove the ‘user-‘ prefix of the DNAnexus username prior to returning it. Returns: The DNAnexus user name. Return type: str
-
gbsc_dnanexus.utils.add_props_to_file(project_id, file_id, props)[source]¶ Makes a call to
dxpy.api.file_set_properties.Any properties with the same name as existing properties on the file will be overwritten. An existing property can also be removed by setting its value to the None object in the passed-in props dictionary.
Parameters: - project_id – str. The DNAnexus project ID in which file_id belongs.
- file_id – str. The ID of the file in DNAnexus to which the props are to be added.
- props – dict. Keys are property names. Use the None object as a value to remove a property.
-
gbsc_dnanexus.utils.strip_dx_userprefix(dx_username)[source]¶ Removes the “user-” prefix of the passed-in DNAnexus username if it is present.
Parameters: dx_username – str. i.e. “user-nathankw”. Returns: The DNAnexus username without a ‘user-‘ prefix. Return type: str
-
gbsc_dnanexus.utils.add_dx_userprefix(dx_username)[source]¶ Adds the “user-” prefix of the passed-in DNAnexus username if it isn’t already present.
Parameters: dx_username – str. i.e. “nathankw”. Returns: The DNAnexus username with a ‘user-‘ prefix. Return type: str
-
gbsc_dnanexus.utils.strip_dx_orgprefix(org)[source]¶ Removes the “org-” prefix of the passed-in DNAnexus org name if it is present.
Parameters: org – str. i.e. “org-scgpm”. Returns: The DNAnexus org ID without the “org-” prefix. Return type: str
-
gbsc_dnanexus.utils.add_dx_orgprefix(org)[source]¶ Adds the ‘org-‘ prefix of the passed-in DNAnexus org name if it isn’t already present.
Parameters: org – str. i.e. “scgpm”. Returns: The DNAnexus org ID. Return type: str
-
gbsc_dnanexus.utils.validate_billed_to_prefix(billing_account_id, exception=False)[source]¶ Checks whether the billing account ID begins with “user-” in the case of an individual billing accout, or “org-” in the case of an org billing account.”
Parameters: - billing_account_id – str. The name of the DNAnexus billing account, specifying either a user billing account or an org billing account.
- exception – bool. If True, then when the validation fails, a gbsc_utils.utils.InvalidBillingAccountId() exception is raised.
Returns: - True if the validation passes, False if the validation fails and the exception
argument is set to False.
Return type: bool
Raises: gbsc_utils.utils.InvalidBillingAccountId() if the validation fails and the ‘exception’ argument is set to True.
-
gbsc_dnanexus.utils.invite_user_to_org_projects(self, org, invitee, created_after, access_level, send_email=False)[source]¶ Invites the specified DNAnexus user (the invitee) to all projects in the specified org (that the current user has access to) with the specified access level.
This is typically used by an admin of the org in order to give himself or another user of the org some access level in each project. Even an admin of the org doesn’t see projects in the org unless they are specifically transferred to or shared with the him.
The dxpy invite method call is idempotent, nonetheless, only projects belonging to the org where the invitee doesn’t have the specified access level are processed. Note that the user making this called should be an admin
Parameters: - created_after – Date (e.g. 2012-01-01) or integer timestamp after which the project was created (negative number means in the past, or use suffix s, m, h, d, w, M, y)”)
- org – str. The name of the DNAnexus org to search for projects to invite the user to.
- invitee – str. The login name of the DNAnexus user to receive the invitations to the projects in the org.
- access_level – str. One of [“VIEW”,”UPLOAD”,”CONTRIBUTE”,”ADMINISTER”], which specifies the permission level that the new member should have on shared projects. See https://wiki.dnanexus.com/API-Specification-v1.0.0/Project-Permissions-and-Sharing for details on the different access levels.
- send_email – bool. True means to allow the dxpy API send an email notification to invitee for each project that invitee is invited to.
Returns: - Each key is a name of a DNAnexus project that the user was invited to, and whose value
is the project’s ID.
Return type: dict