示例#1
0
 def get_chrom_info(self,
                    dbkey,
                    trans=None,
                    custom_build_hack_get_len_from_fasta_conversion=True):
     # FIXME: flag to turn off custom_build_hack_get_len_from_fasta_conversion should not be required
     chrom_info = None
     db_dataset = None
     # Collect chromInfo from custom builds
     if trans:
         db_dataset = trans.db_dataset_for(dbkey)
         if db_dataset:
             chrom_info = db_dataset.file_name
         else:
             # Do Custom Build handling
             if trans.user and ('dbkeys' in trans.user.preferences) and (
                     dbkey in loads(trans.user.preferences['dbkeys'])):
                 custom_build_dict = loads(
                     trans.user.preferences['dbkeys'])[dbkey]
                 # HACK: the attempt to get chrom_info below will trigger the
                 # fasta-to-len converter if the dataset is not available or,
                 # which will in turn create a recursive loop when
                 # running the fasta-to-len tool. So, use a hack in the second
                 # condition below to avoid getting chrom_info when running the
                 # fasta-to-len converter.
                 if 'fasta' in custom_build_dict and custom_build_hack_get_len_from_fasta_conversion:
                     # Build is defined by fasta; get len file, which is obtained from converting fasta.
                     build_fasta_dataset = trans.sa_session.query(
                         trans.app.model.HistoryDatasetAssociation).get(
                             custom_build_dict['fasta'])
                     chrom_info = build_fasta_dataset.get_converted_dataset(
                         trans, 'len').file_name
                 elif 'len' in custom_build_dict:
                     # Build is defined by len file, so use it.
                     chrom_info = trans.sa_session.query(
                         trans.app.model.HistoryDatasetAssociation).get(
                             custom_build_dict['len']).file_name
     # Check Data table
     if not chrom_info:
         dbkey_table = self._app.tool_data_tables.get(
             self._data_table_name, None)
         if dbkey_table is not None:
             chrom_info = dbkey_table.get_entry('value',
                                                dbkey,
                                                'len_path',
                                                default=None)
     # use configured server len path
     if not chrom_info:
         # Default to built-in build.
         # Since we are using an unverified dbkey, we will sanitize the dbkey before use
         chrom_info = os.path.join(
             self._static_chrom_info_path,
             "%s.len" % sanitize_lists_to_string(dbkey))
     chrom_info = os.path.abspath(chrom_info)
     return (chrom_info, db_dataset)
示例#2
0
 def get_chrom_info(self, dbkey, trans=None, custom_build_hack_get_len_from_fasta_conversion=True):
     # FIXME: flag to turn off custom_build_hack_get_len_from_fasta_conversion should not be required
     chrom_info = None
     db_dataset = None
     # Collect chromInfo from custom builds
     if trans:
         db_dataset = trans.db_dataset_for(dbkey)
         if db_dataset:
             chrom_info = db_dataset.file_name
         else:
             # Do Custom Build handling
             if trans.user and ('dbkeys' in trans.user.preferences) and (dbkey in loads(trans.user.preferences['dbkeys'])):
                 custom_build_dict = loads(trans.user.preferences['dbkeys'])[dbkey]
                 # HACK: the attempt to get chrom_info below will trigger the
                 # fasta-to-len converter if the dataset is not available or,
                 # which will in turn create a recursive loop when
                 # running the fasta-to-len tool. So, use a hack in the second
                 # condition below to avoid getting chrom_info when running the
                 # fasta-to-len converter.
                 if 'fasta' in custom_build_dict and custom_build_hack_get_len_from_fasta_conversion:
                     # Build is defined by fasta; get len file, which is obtained from converting fasta.
                     build_fasta_dataset = trans.sa_session.query(trans.app.model.HistoryDatasetAssociation).get(custom_build_dict['fasta'])
                     chrom_info = build_fasta_dataset.get_converted_dataset(trans, 'len').file_name
                 elif 'len' in custom_build_dict:
                     # Build is defined by len file, so use it.
                     chrom_info = trans.sa_session.query(trans.app.model.HistoryDatasetAssociation).get(custom_build_dict['len']).file_name
     # Check Data table
     if not chrom_info:
         dbkey_table = self._app.tool_data_tables.get(self._data_table_name, None)
         if dbkey_table is not None:
             chrom_info = dbkey_table.get_entry('value', dbkey, 'len_path', default=None)
     # use configured server len path
     if not chrom_info:
         # Default to built-in build.
         # Since we are using an unverified dbkey, we will sanitize the dbkey before use
         chrom_info = os.path.join(self._static_chrom_info_path, "%s.len" % sanitize_lists_to_string(dbkey))
     chrom_info = os.path.abspath(chrom_info)
     return (chrom_info, db_dataset)
示例#3
0
 def to_safe_string(self, value):
     return sanitize_lists_to_string(self.to_string(value))
示例#4
0
 def to_safe_string( self, value ):
     return sanitize_lists_to_string( self.to_string( value ) )