original_docstring:  Given a graph, then we extract two threads from the
          given sample as their own graphs, then return an xg index for each.
          this only supports one chromosome at a time, presently.
          the indexes are written as thread_0.xg and thread_1.xg in the
          output store (derived from tag parameter like other methods)
          
          Returns paths to a full xg file for the graph, an xg for haplotype 0 of
          the sample, and an xg for haplotype 1 of the sample.
          
          
docstring: Given a graph, then we extract two threads from the
  given sample as their own graphs, then return an xg index for each.
  this only supports one chromosome at a time, presently.
  the indexes are written as thread_0.xg and thread_1.xg in the
  output store (derived from tag parameter like other methods)
  
  Returns paths to a full xg file for the graph, an xg for haplotype 0 of
  the sample, and an xg for haplotype 1 of the sample.
docstring_tokens: Given a graph then we extract two threads from the given sample as their own graphs then return an xg index for each . this only supports one chromosome at a time presently . the indexes are written as thread_0 . xg and thread_1 . xg in the output store ( derived from tag parameter like other methods ) Returns paths to a full xg file for the graph an xg for haplotype 0 of the sample and an xg for haplotype 1 of the sample .
code: def _make_thread_indexes(self, sample, vg_file, vcf_file, region, tag=''):
          """ Given a graph, then we extract two threads from the
          given sample as their own graphs, then return an xg index for each.
          this only supports one chromosome at a time, presently.
          the indexes are written as thread_0.xg and thread_1.xg in the
          output store (derived from tag parameter like other methods)
          
          Returns paths to a full xg file for the graph, an xg for haplotype 0 of
          the sample, and an xg for haplotype 1 of the sample.
          
          """
          
          job_store = self._jobstore(tag)
          out_store = self._outstore(tag)
          out_store_name = self._outstore_name(tag)
  
          # What do we want to override from the default toil-vg config?
          overrides = argparse.Namespace(
              # toil-vg options
              vg_docker = self.vg_docker,
              container = self.container,
              force_outstore = self.force_outstore,
              # Toil options
              realTimeLogging = True,
              realTimeStderr = True,
              logLevel = "INFO",
              maxCores = self.cores
          )
  
          # Make the context
          context = Context(out_store, overrides)
  
          # The unfiltered and filtered vcf file
          uf_vcf_file = os.path.join(self.workdir, 'uf-' + os.path.basename(vcf_file))
          f_vcf_file = os.path.join(self.workdir, 'f-' + os.path.basename(vcf_file))
          if not f_vcf_file.endswith('.gz'):
              f_vcf_file += '.gz'
          
          # Get the inputs
          self._get_remote_file(vg_file, os.path.join(out_store, os.path.basename(vg_file)))
          self._get_remote_file(vcf_file, uf_vcf_file)
  
          # Reduce our VCF to just the sample of interest to save time downstream
          with context.get_toil(job_store) as toil:
              cmd = ['bcftools', 'view', os.path.basename(uf_vcf_file), '-s', sample, '-O', 'z']
              toil.start(Job.wrapJobFn(toil_call, context, cmd,
                                       work_dir = os.path.abspath(self.workdir),
                                       out_path = os.path.abspath(f_vcf_file)))
              cmd = ['tabix', '-f', '-p', 'vcf', os.path.basename(f_vcf_file)]
              toil.start(Job.wrapJobFn(toil_call, context, cmd,
                                       work_dir = os.path.abspath(self.workdir)))
          os.remove(uf_vcf_file)
  
          # Make the gbwt of the input graph
          index_name = 'index-gbwt'
          chrom, offset = self._bakeoff_coords(region)
          self._toil_vg_index(chrom, vg_file, None, 'SKIP',
                              '--vcf_phasing {} --xg_index_cores {} --gbwt_index'.format(
                                  os.path.abspath(f_vcf_file), self.cores), tag, index_name)
          gbwt_path = os.path.join(out_store, index_name + '.gbwt')
          xg_path = os.path.join(out_store, index_name + '.xg')
          
          os.remove(f_vcf_file)
          os.remove(f_vcf_file + '.tbi')
          
          # Extract both haplotypes of the given sample as their own graphs
          with context.get_toil(job_store) as toil:
              main_job = Job.wrapJobFn(run_make_haplo_thread_graphs,
                                       context,
                                       toil.importFile(make_url(vg_file)),
                                       os.path.basename(vg_file),
                                       'baseline',
                                       [chrom],
                                       toil.importFile(make_url(xg_path)),
                                       sample,
                                       [0,1],
                                       toil.importFile(make_url(gbwt_path)))
              haplo_ids = toil.start(main_job)
              thread_0_file = os.path.join(out_store, 'thread_0')
              thread_1_file = os.path.join(out_store, 'thread_1')
              toil.exportFile(haplo_ids[0], make_url(thread_0_file + '.vg'))
              toil.exportFile(haplo_ids[1], make_url(thread_1_file + '.vg'))
  
          # then index them
          for thread_vg in [thread_0_file, thread_1_file]:
              self._toil_vg_index(chrom, thread_vg + '.vg', None, 'SKIP', None, tag,
                                  os.path.basename(thread_vg))
  
          return xg_path, thread_0_file + '.xg', thread_1_file + '.xg'
code_tokens: def _make_thread_indexes ( self , sample , vg_file , vcf_file , region , tag = '' ) : job_store = self . _jobstore ( tag ) out_store = self . _outstore ( tag ) out_store_name = self . _outstore_name ( tag ) overrides = argparse . Namespace ( vg_docker = self . vg_docker , container = self . container , force_outstore = self . force_outstore , realTimeLogging = True , realTimeStderr = True , logLevel = "INFO" , maxCores = self . cores ) context = Context ( out_store , overrides ) uf_vcf_file = os . path . join ( self . workdir , 'uf-' + os . path . basename ( vcf_file ) ) f_vcf_file = os . path . join ( self . workdir , 'f-' + os . path . basename ( vcf_file ) ) if not f_vcf_file . endswith ( '.gz' ) : f_vcf_file += '.gz' self . _get_remote_file ( vg_file , os . path . join ( out_store , os . path . basename ( vg_file ) ) ) self . _get_remote_file ( vcf_file , uf_vcf_file ) with context . get_toil ( job_store ) as toil : cmd = [ 'bcftools' , 'view' , os . path . basename ( uf_vcf_file ) , '-s' , sample , '-O' , 'z' ] toil . start ( Job . wrapJobFn ( toil_call , context , cmd , work_dir = os . path . abspath ( self . workdir ) , out_path = os . path . abspath ( f_vcf_file ) ) ) cmd = [ 'tabix' , '-f' , '-p' , 'vcf' , os . path . basename ( f_vcf_file ) ] toil . start ( Job . wrapJobFn ( toil_call , context , cmd , work_dir = os . path . abspath ( self . workdir ) ) ) os . remove ( uf_vcf_file ) index_name = 'index-gbwt' chrom , offset = self . _bakeoff_coords ( region ) self . _toil_vg_index ( chrom , vg_file , None , 'SKIP' , '--vcf_phasing {} --xg_index_cores {} --gbwt_index' . format ( os . path . abspath ( f_vcf_file ) , self . cores ) , tag , index_name ) gbwt_path = os . path . join ( out_store , index_name + '.gbwt' ) xg_path = os . path . join ( out_store , index_name + '.xg' ) os . remove ( f_vcf_file ) os . remove ( f_vcf_file + '.tbi' ) with context . get_toil ( job_store ) as toil : main_job = Job . wrapJobFn ( run_make_haplo_thread_graphs , context , toil . importFile ( make_url ( vg_file ) ) , os . path . basename ( vg_file ) , 'baseline' , [ chrom ] , toil . importFile ( make_url ( xg_path ) ) , sample , [ 0 , 1 ] , toil . importFile ( make_url ( gbwt_path ) ) ) haplo_ids = toil . start ( main_job ) thread_0_file = os . path . join ( out_store , 'thread_0' ) thread_1_file = os . path . join ( out_store , 'thread_1' ) toil . exportFile ( haplo_ids [ 0 ] , make_url ( thread_0_file + '.vg' ) ) toil . exportFile ( haplo_ids [ 1 ] , make_url ( thread_1_file + '.vg' ) ) for thread_vg in [ thread_0_file , thread_1_file ] : self . _toil_vg_index ( chrom , thread_vg + '.vg' , None , 'SKIP' , None , tag , os . path . basename ( thread_vg ) ) return xg_path , thread_0_file + '.xg' , thread_1_file + '.xg'
short_docstring: Given a graph, then we extract two threads from the
  given sample as their own graphs, then return an xg index for each.
short_docstring_tokens: Given a graph then we extract two threads from the given sample as their own graphs then return an xg index for each .
comment: """ Given a graph, then we extract two threads from the
          given sample as their own graphs, then return an xg index for each.
          this only supports one chromosome at a time, presently.
          the indexes are written as thread_0.xg and thread_1.xg in the
          output store (derived from tag parameter like other methods)
          
          Returns paths to a full xg file for the graph, an xg for haplotype 0 of
          the sample, and an xg for haplotype 1 of the sample.
          
          """$SEP$# What do we want to override from the default toil-vg config?$SEP$# toil-vg options$SEP$# Toil options$SEP$# Make the context$SEP$# The unfiltered and filtered vcf file$SEP$# Get the inputs$SEP$# Reduce our VCF to just the sample of interest to save time downstream$SEP$# Make the gbwt of the input graph$SEP$# Extract both haplotypes of the given sample as their own graphs$SEP$# then index them