<commit_before>import { fetchWithCreds } from '../../actions';
import { constructGraphQLQuery, hasKeyChain, MSG_FAILED_DOWNLOAD } from '../utils.js';

export const getBDBagQuery = referenceIDList => `{
            participants: 
              case(first:0, submitter_id: ["${referenceIDList.join('","')}"])
              {
                 _participant_id:submitter_id
              }
              samples:sample(first:0, with_path_to_any:[
              ${referenceIDList.map(item => (`{type: "case", submitter_id: "${item}"}`))}
              ]) {
                composition
                submitter_specimen_type:biospecimen_anatomic_site
                cases {
                    participant:submitter_id
                    donor_uuid:id
                    project:project_id
                }
                
                aliquots(first:0){
                    submitter_sample_id:submitter_id
                    _sample_id:id
                    read_groups(first:0){
                        center_name:sequencing_center
                        submitter_experimental_design:library_strategy
                        platform
                        submitted_unaligned_reads_files{
                           file_type0:data_format
                           file_dos_uri0:object_id
                           upload_file_id0:object_id
                           file_path0:file_name
                        }      
                        submitted_aligned_reads_files{
                           file_type2:data_format
                           upload_file_id2:object_id
                           file_dos_uri2:object_id
                           file_path2:file_name
                           aligned_reads_indexes{
                               file_type1:data_format
                               upload_file_id1:object_id
                               file_dos_uri1:object_id
                               file_path1:file_name            
                           }
                        }                                                      
                    }
                }
            }
          }`;

export const exportToCloud = async (
  apiFunc,
  projectId,
  selectedTableRows,
  arrangerConfig,
) => {
  if (!hasKeyChain(arrangerConfig, 'table.referenceId')) {
    throw MSG_FAILED_DOWNLOAD;
  }
  const referenceID = arrangerConfig.table.referenceId;
  const getIDQueryString = constructGraphQLQuery(<commit_msg>feat(bdbagvcf): Add vcfs to the bdbags (#399)<commit_after>import { fetchWithCreds } from '../../actions';
import { constructGraphQLQuery, hasKeyChain, MSG_FAILED_DOWNLOAD } from '../utils.js';

export const getBDBagQuery = referenceIDList => `{
            participants: 
              case(first:0, submitter_id: ["${referenceIDList.join('","')}"])
              {
                 _participant_id:submitter_id
              }
              samples:sample(first:0, with_path_to_any:[
              ${referenceIDList.map(item => (`{type: "case", submitter_id: "${item}"}`))}
              ]) {
                composition
                submitter_specimen_type:biospecimen_anatomic_site
                cases {
                    participant:submitter_id
                    donor_uuid:id
                    project:project_id
                }
                
                aliquots(first:0){
                    submitter_sample_id:submitter_id
                    _sample_id:id
                    read_groups(first:0){
                        center_name:sequencing_center
                        submitter_experimental_design:library_strategy
                        platform
                        submitted_unaligned_reads_files{
                           file_type0:data_format
                           file_dos_uri0:object_id
                           upload_file_id0:object_id
                           file_path0:file_name
                        }      
                        submitted_aligned_reads_files{
                           file_type2:data_format
                           upload_file_id2:object_id
                           file_dos_uri2:object_id
                           file_path2:file_name
                           aligned_reads_indexes{
                               file_type1:data_format
                               upload_file_id1:object_id
                               file_dos_uri1:object_id
                               file_path1:file_name            
                           }
                           simple_germline_variations{
                               file_type3:data_format
                               upload_file_id3:object_id
                               file_dos_uri3:object_id
                               file_path3:file_name
                          }
                        }                                                      
                    }
                }
            }
          }`;

export const exportToCloud = async (
  apiFunc,
  projectId,
  selectedTableRows,
  arrangerConfig,
) => {
  if (!hasKeyChain(arrangerConfig, 'table.referenceId')) {
    throw MSG_FAILED_DOWNLOAD;
  }
  const referenceID = arrangerConfig.table.referenceId;
  const getIDQueryString = constructGraphQLQuery(
{'fraction_non_alphanumeric': 0.06187132283165686, 'fraction_numerical': 0.00740178401973809, 'mean_word_length': 1.0962609387430389, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5607482', 'n_tokens_mistral': 1308, 'n_tokens_neox': 1251, 'n_words': 156}