Esempio n. 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.

    Returns:
      A list of reads that meet the search criteria.
    """
        apitools_client = genomics_util.GetGenomicsClient()
        messages = genomics_util.GetGenomicsMessages()
        fields = genomics_util.GetQueryFields(self.GetReferencedKeyNames(args),
                                              'alignments')
        if fields:
            global_params = messages.StandardQueryParameters(fields=fields)
        else:
            global_params = None

        return list_pager.YieldFromList(
            apitools_client.reads,
            messages.SearchReadsRequest(
                readGroupSetIds=[args.read_group_set_id],
                referenceName=args.reference_name,
                start=args.start,
                end=args.end),
            global_params=global_params,
            limit=args.limit,
            method='Search',
            batch_size_attribute='pageSize',
            batch_size=args.page_size,
            field='alignments')
Esempio n. 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.

    Returns:
      A list of reads that meet the search criteria.
    """
        genomics_util.ValidateLimitFlag(args.limit)

        apitools_client = self.context[lib.GENOMICS_APITOOLS_CLIENT_KEY]
        messages = self.context[lib.GENOMICS_MESSAGES_MODULE_KEY]
        fields = genomics_util.GetQueryFields(self.GetReferencedKeyNames(args),
                                              'alignments')
        if fields:
            global_params = messages.StandardQueryParameters(fields=fields)
        else:
            global_params = None

        pager = list_pager.YieldFromList(
            apitools_client.reads,
            messages.SearchReadsRequest(
                readGroupSetIds=[args.read_group_set_id],
                referenceName=args.reference_name,
                start=args.start,
                end=args.end),
            global_params=global_params,
            limit=args.limit,
            method='Search',
            batch_size_attribute='pageSize',
            batch_size=args.page_size,
            field='alignments')
        return genomics_util.ReraiseHttpExceptionPager(pager)
Esempio n. 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.

    Yields:
      A list of variants that meet the search criteria.
    """
        apitools_client = genomics_util.GetGenomicsClient()
        genomics_messages = genomics_util.GetGenomicsMessages()

        fields = genomics_util.GetQueryFields(self.GetReferencedKeyNames(args),
                                              'variants')
        if fields:
            global_params = genomics_messages.StandardQueryParameters(
                fields=fields)
        else:
            global_params = None

        variant_set_id = [args.variant_set_id] if args.variant_set_id else []
        try:
            for resource in list_pager.YieldFromList(
                    apitools_client.variants,
                    genomics_messages.SearchVariantsRequest(
                        variantSetIds=variant_set_id,
                        callSetIds=args.call_set_ids,
                        referenceName=args.reference_name,
                        start=args.start,
                        end=args.end,
                        maxCalls=args.limit_calls),
                    global_params=global_params,
                    limit=args.limit,
                    method='Search',
                    batch_size_attribute='pageSize',
                    batch_size=args.page_size,
                    field='variants'):
                yield resource
        except apitools_exceptions.HttpError as error:
            msg = (
                exceptions.HttpException(error).payload.status_message.replace(
                    'variantSetIds', '--variant-set-id').replace(
                        'callSetIds', '--call-set-ids').replace(
                            'referenceName', '--reference-name').replace(
                                'start', '--start').replace('end', '--end'))
            raise exceptions.HttpException(msg)
Esempio n. 4
0
    def Run(self, args):
        """Run 'readgroupsets list'.

    Args:
      args: argparse.Namespace, The arguments that this command was invoked
          with.

    Returns:
      The list of read group sets matching the given dataset ids.

    Raises:
      HttpException: An http error response was received while executing api
          request.
    """
        genomics_util.ValidateLimitFlag(args.limit)

        apitools_client = self.context[lib.GENOMICS_APITOOLS_CLIENT_KEY]
        req_class = (self.context[
            lib.GENOMICS_MESSAGES_MODULE_KEY].SearchReadGroupSetsRequest)
        messages = self.context[lib.GENOMICS_MESSAGES_MODULE_KEY]
        fields = genomics_util.GetQueryFields(self.GetReferencedKeyNames(args),
                                              'readGroupSets')
        if fields:
            global_params = messages.StandardQueryParameters(fields=fields)
        else:
            global_params = None

        page_size = args.page_size
        if args.limit and args.limit < page_size:
            page_size = args.limit

        pager = list_pager.YieldFromList(apitools_client.readgroupsets,
                                         req_class(
                                             name=args.name,
                                             datasetIds=args.dataset_ids),
                                         method='Search',
                                         global_params=global_params,
                                         limit=args.limit,
                                         batch_size_attribute='pageSize',
                                         batch_size=page_size,
                                         field='readGroupSets')
        return genomics_util.ReraiseHttpExceptionPager(pager)
Esempio n. 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:
      A list of variants that meet the search criteria.
    """
        apitools_client = genomics_util.GetGenomicsClient()
        genomics_messages = genomics_util.GetGenomicsMessages()

        fields = genomics_util.GetQueryFields(self.GetReferencedKeyNames(args),
                                              'variants')
        if fields:
            global_params = genomics_messages.StandardQueryParameters(
                fields=fields)
        else:
            global_params = None

        variant_set_id = [args.variant_set_id] if args.variant_set_id else []
        pager = list_pager.YieldFromList(
            apitools_client.variants,
            genomics_messages.SearchVariantsRequest(
                variantSetIds=variant_set_id,
                callSetIds=args.call_set_ids,
                referenceName=args.reference_name,
                start=args.start,
                end=args.end,
                maxCalls=args.limit_calls),
            global_params=global_params,
            limit=args.limit,
            method='Search',
            batch_size_attribute='pageSize',
            batch_size=args.page_size,
            field='variants')
        return genomics_util.ReraiseHttpExceptionPager(pager,
                                                       self.RewriteError)
Esempio n. 6
0
  def Run(self, args):
    """Run 'readgroupsets list'.

    Args:
      args: argparse.Namespace, The arguments that this command was invoked
          with.

    Returns:
      The list of read group sets matching the given dataset ids.

    Raises:
      HttpException: An http error response was received while executing api
          request.
    """
    apitools_client = genomics_util.GetGenomicsClient()
    messages = genomics_util.GetGenomicsMessages()
    req_class = messages.SearchReadGroupSetsRequest
    fields = genomics_util.GetQueryFields(
        self.GetReferencedKeyNames(args), 'readGroupSets')
    if fields:
      global_params = messages.StandardQueryParameters(fields=fields)
    else:
      global_params = None

    page_size = args.page_size
    if args.limit and args.limit < page_size:
      page_size = args.limit

    return list_pager.YieldFromList(apitools_client.readgroupsets,
                                    req_class(name=args.name,
                                              datasetIds=args.dataset_ids),
                                    method='Search',
                                    global_params=global_params,
                                    limit=args.limit,
                                    batch_size_attribute='pageSize',
                                    batch_size=page_size,
                                    field='readGroupSets')