Beispiel #1
0
    def Run(self, args):
        """This is what gets called when the user runs this command.

    Args:
      args: an argparse namespace, All the arguments that were provided to this
        command invocation.

    Raises:
      HttpException: An http error response was received while executing api
          request.
      GenomicsError: if canceled by the user.
    Returns:
      None
    """

        prompt_message = (
            'Deleting variant set {0} will delete all its contents '
            '(variants, callsets, and calls). '
            'The variant set object is not deleted.').format(
                args.variant_set_id)

        if not console_io.PromptContinue(message=prompt_message):
            raise GenomicsError('Deletion aborted by user.')

        apitools_client = self.context[lib.GENOMICS_APITOOLS_CLIENT_KEY]
        genomics_messages = self.context[lib.GENOMICS_MESSAGES_MODULE_KEY]

        req = genomics_messages.GenomicsVariantsetsDeleteRequest(
            variantSetId=str(args.variant_set_id), )

        ret = apitools_client.variantsets.Delete(req)
        log.DeletedResource('{0}'.format(args.variant_set_id))
        return ret
Beispiel #2
0
    def Run(self, args):
        """This is what gets called when the user runs this command.

    Args:
      args: an argparse namespace, All the arguments that were provided to this
        command invocation.

    Raises:
      HttpException: An http error response was received while executing api
          request.
    Returns:
      None
    """
        # Look it up first so that we can display the name
        existing_cs = genomics_util.GetCallSet(self.context, args.id)
        prompt_message = (
            'Deleting call set {0} ({1}) will delete all objects in the '
            'call set.').format(existing_cs.id, existing_cs.name)
        if not console_io.PromptContinue(message=prompt_message):
            raise GenomicsError('Deletion aborted by user.')
        apitools_client = self.context[lib.GENOMICS_APITOOLS_CLIENT_KEY]
        genomics_messages = self.context[lib.GENOMICS_MESSAGES_MODULE_KEY]
        call_set = genomics_messages.GenomicsCallsetsDeleteRequest(
            callSetId=args.id, )

        apitools_client.callsets.Delete(call_set)
        log.DeletedResource('{0} ({1})'.format(existing_cs.id,
                                               existing_cs.name))
Beispiel #3
0
  def Run(self, args):
    """This is what gets called when the user runs this command.

    Args:
      args: an argparse namespace, All the arguments that were provided to this
        command invocation.

    Raises:
      HttpException: An http error response was received while executing api
          request.
    Returns:
      None
    """
    apitools_client = self.context[lib.GENOMICS_APITOOLS_CLIENT_KEY]
    genomics_messages = self.context[lib.GENOMICS_MESSAGES_MODULE_KEY]

    # Look it up first so that we can display it
    op = apitools_client.operations.Get(
        genomics_messages.GenomicsOperationsGetRequest(name=args.name))
    self.format(op)

    if not console_io.PromptContinue(message='This operation will be canceled'):
      raise GenomicsError('Cancel aborted by user.')

    apitools_client.operations.Cancel(
        genomics_messages.GenomicsOperationsCancelRequest(name=args.name))
    log.status.write('Canceled [{0}].\n'.format(args.name))
Beispiel #4
0
    def Run(self, args):
        """This is what gets called when the user runs this command.

    Args:
      args: an argparse namespace, All the arguments that were provided to this
        command invocation.

    Raises:
      HttpException: An http error response was received while executing api
          request.
    Returns:
      None
    """
        prompt_message = (
            'Deleting dataset {0} will delete all objects in the dataset. '
            'Deleted datasets can be recovered with the "restore" command '
            'up to one week after the deletion occurs.').format(args.id)

        if not console_io.PromptContinue(message=prompt_message):
            raise GenomicsError('Deletion aborted by user.')

        apitools_client = self.context[commands.GENOMICS_APITOOLS_CLIENT_KEY]
        genomics_messages = self.context[commands.GENOMICS_MESSAGES_MODULE_KEY]

        dataset = genomics_messages.GenomicsDatasetsDeleteRequest(
            datasetId=str(args.id), )

        apitools_client.datasets.Delete(dataset)
        log.Print('Deleted dataset {0}'.format(args.id))
Beispiel #5
0
    def Run(self, args):
        """This is what gets called when the user runs this command.

    Args:
      args: an argparse namespace, All the arguments that were provided to this
        command invocation.

    Returns:
      an Operation message which tracks the asynchronous import
    """
        apitools_client = self.context[lib.GENOMICS_APITOOLS_CLIENT_KEY]
        genomics_messages = self.context[lib.GENOMICS_MESSAGES_MODULE_KEY]

        if not args.source_uris:
            raise GenomicsError(
                'at least one value is required for --source-uris')

        partition_enum = (genomics_messages.ImportReadGroupSetsRequest.
                          PartitionStrategyValueValuesEnum)
        partition_strat = None
        if args.partition_strategy:
            if args.partition_strategy not in partition_enum.to_dict():
                raise GenomicsError(
                    '--partition-strategy must be one of {0}; received: {1}'.
                    format(sorted(partition_enum.names()),
                           args.partition_strategy))
            partition_strat = partition_enum.lookup_by_name(
                args.partition_strategy)

        try:
            return apitools_client.readgroupsets.Import(
                genomics_messages.ImportReadGroupSetsRequest(
                    datasetId=args.dataset_id,
                    sourceUris=args.source_uris,
                    referenceSetId=args.reference_set_id,
                    partitionStrategy=partition_strat,
                ))
        except apitools_base.HttpError as error:
            # Map our error messages (JSON API camelCased) back into flag names.
            msg = (genomics_util.GetErrorMessage(error).replace(
                'datasetId', '--dataset-id').replace(
                    'partitionStrategy', '--partition-strategy').replace(
                        'sourceUris',
                        '--source-uris').replace('referenceSetId',
                                                 '--reference-set-id'))
            unused_type, unused_value, traceback = sys.exc_info()
            raise exceptions.HttpException, msg, traceback
def ValidateLimitFlag(limit):
  """Validates a limit flag value.

  Args:
    limit: the limit flag value to sanitize.
  Raises:
    GenomicsError: if the provided limit flag value is negative
  """
  if limit is None:
    return

  if limit < 0:
    raise GenomicsError(
        '--limit must be a non-negative integer; received: {0}'
        .format(limit))
Beispiel #7
0
def ValidateLimitFlag(limit, flag_name='limit'):
  """Validates a limit flag value.

  Args:
    limit: the limit flag value to sanitize.
    flag_name: the name of the limit flag - defaults to limit
  Raises:
    GenomicsError: if the provided limit flag value is negative
  """
  if limit is None:
    return

  if limit < 0:
    raise GenomicsError(
        '--{0} must be a non-negative integer; received: {1}'
        .format(flag_name, limit))