예제 #1
0
def gen_all_samples_from_soft_and_isamp(soft_files, isamp_file_or_str, config):
    """
    :param isamp: e.g. mannually prepared interested sample file
    (e.g. GSE_species_GSM.csv) or isamp_str as specified on the command

    :type isamp: a dict with key and value as listing of strings, not Sample
    instances
    """
    # IMPORTANT NOTE: for historical reason, soft files parsed does not return
    # dict as get_isamp
    isamp = get_isamp(isamp_file_or_str)
    log_isamp(isamp_file_or_str, isamp)

    # a list, of Sample instances resultant of intersection
    intersected_samples = []
    for soft_file in soft_files:
        soft_samples = analyze_one(soft_file, isamp, config['INTERESTED_ORGANISMS'])
        if soft_samples:
            intersected_samples.extend(soft_samples)
    num_inter_samp = len(intersected_samples)
    sanity_check(calc_num_isamp(isamp), num_inter_samp)
    return intersected_samples
예제 #2
0
def gen_all_samples_from_soft_and_isamp(soft_files, isamp_file_or_str, config):
    """
    :param isamp: e.g. mannually prepared interested sample file
    (e.g. GSE_species_GSM.csv) or isamp_str as specified on the command

    :type isamp: a dict with key and value as listing of strings, not Sample
    instances
    """
    # IMPORTANT NOTE: for historical reason, soft files parsed does not return
    # dict as get_isamp
    isamp = get_isamp(isamp_file_or_str)
    log_isamp(isamp_file_or_str, isamp)

    # a list, of Sample instances resultant of intersection
    intersected_samples = []
    for soft_file in soft_files:
        soft_samples = analyze_one(soft_file, isamp,
                                   config['INTERESTED_ORGANISMS'])
        if soft_samples:
            intersected_samples.extend(soft_samples)
    num_inter_samp = len(intersected_samples)
    sanity_check(calc_num_isamp(isamp), num_inter_samp)
    return intersected_samples
예제 #3
0
 def test_get_isamp_from_str(self, mock_exists, mock_gen_isamp_from_csv):
     mock_exists.return_value = False
     self.assertEqual(isamp_parser.get_isamp('GSE1 GSM1'),
                      {'GSE1': ['GSM1']})
     self.assertFalse(mock_gen_isamp_from_csv.called)
예제 #4
0
 def test_get_isamp_from_csv(self, mock_exists, mock_gen_isamp_from_csv,
                             mock_gen_isamp_from_str):
     mock_exists.return_value = True
     isamp_parser.get_isamp('GSE_species_GSM.csv')
     mock_gen_isamp_from_csv.called_once_with('GSE_species_GSM.csv')
     self.assertFalse(mock_gen_isamp_from_str.called)
예제 #5
0
 def test_get_isamp_from_str(self, mock_exists, mock_gen_isamp_from_csv):
     mock_exists.return_value = False
     self.assertEqual(isamp_parser.get_isamp('GSE1 GSM1'), {'GSE1': ['GSM1']})
     self.assertFalse(mock_gen_isamp_from_csv.called)
예제 #6
0
 def test_get_isamp_from_csv(self, mock_exists, mock_gen_isamp_from_csv,
                             mock_gen_isamp_from_str):
     mock_exists.return_value = True
     isamp_parser.get_isamp('GSE_species_GSM.csv')
     mock_gen_isamp_from_csv.called_once_with('GSE_species_GSM.csv')
     self.assertFalse(mock_gen_isamp_from_str.called)