<commit_before>"""Create a new family report with no genome
"""

import csv
import json
import os
import requests
from requests.auth import HTTPBasicAuth
import sys

#Load environment variables for request authentication parameters
if "OMICIA_API_PASSWORD" not in os.environ:
    sys.exit("OMICIA_API_PASSWORD environment variable missing")

if "OMICIA_API_LOGIN" not in os.environ:
    sys.exit("OMICIA_API_LOGIN environment variable missing")

OMICIA_API_LOGIN = os.environ['OMICIA_API_LOGIN']
OMICIA_API_PASSWORD = os.environ['OMICIA_API_PASSWORD']
OMICIA_API_URL = os.environ.get('OMICIA_API_URL', 'https://api.omicia.com')
auth = HTTPBasicAuth(OMICIA_API_LOGIN, OMICIA_API_PASSWORD)

def launch_family_report(score_indels, reporting_cutoff, accession_id):
    """Launch a family report. Return the JSON response.
    """
    # Construct url and request
    url = "{}/reports/".format(OMICIA_API_URL)
    url_payload = {'report_type': "Family Report, Trio",
                   'mother_genome_id': None,
                   'father_genome_id': None,
                   'proband_genome_id': None,
                   'proband_sex': None,
                   'background': 'FULL',
                   'score_indels': bool(score_indels),
                   'reporting_cutoff': int(reporting_cutoff),
                   'accession_id': accession_id}

    sys.stdout.write("Launching family report...\n")
    result = requests.post(url, auth=auth, data=json.dumps(url_payload))

    return result.json()


def main(argv):
    """Main function, creates a panel report.
    """
    if len(argv) < 3:
        sys.exit("Usage: python launch_family_report.py \
        <score_indels> <reporting_cutoff> <accession_id>")
    score_indels = argv[0]
    reporting_cutoff = argv[1]
    accession_id = argv[2]

    family_report_json = launch_family_report(
        score_indels,
        reporting_cutoff,
        accession_id)

    # Confirm launched report data
    sys.stdout.write("\n")

    if "clinical_report" not in family_report_json.keys():
        print family_report_json
        sys.exit("Failed to launch. Check report parameters for correctness.")
    clinical_report = family_report_json['clinical_report']
    sys.stdout.write('Launched Family Report:\n'
                     'id: {}\n'
                     'test_type: {}\n'
                     'accession_id: {}\n'
                     'created_on: {}\n'
                     'created_by: {}\n'
                     'status: {}\n'
                     'filter_id: {}\n'
                     'filter_name: {}\n'
                     'panel_id: {}\n'
                     'workspace_id: {}\n'
                     'sample_collected_date: {}\n'
                     'sample_received_date: {}\n'
                     'include_cosmic: {}\n'
                     'vaast_report_id: {}\n'
                     'mother_genome_id: {}\n'
                     'father_genome_id: {}\n'
                     'genome_id: {}\n'
                     'status: {}\n'
                     'version: {}\n'<commit_msg>family report printout had an extra status<commit_after>"""Create a new family report with no genome
"""

import csv
import json
import os
import requests
from requests.auth import HTTPBasicAuth
import sys

#Load environment variables for request authentication parameters
if "OMICIA_API_PASSWORD" not in os.environ:
    sys.exit("OMICIA_API_PASSWORD environment variable missing")

if "OMICIA_API_LOGIN" not in os.environ:
    sys.exit("OMICIA_API_LOGIN environment variable missing")

OMICIA_API_LOGIN = os.environ['OMICIA_API_LOGIN']
OMICIA_API_PASSWORD = os.environ['OMICIA_API_PASSWORD']
OMICIA_API_URL = os.environ.get('OMICIA_API_URL', 'https://api.omicia.com')
auth = HTTPBasicAuth(OMICIA_API_LOGIN, OMICIA_API_PASSWORD)

def launch_family_report(score_indels, reporting_cutoff, accession_id):
    """Launch a family report. Return the JSON response.
    """
    # Construct url and request
    url = "{}/reports/".format(OMICIA_API_URL)
    url_payload = {'report_type': "Family Report, Trio",
                   'mother_genome_id': None,
                   'father_genome_id': None,
                   'proband_genome_id': None,
                   'proband_sex': None,
                   'background': 'FULL',
                   'score_indels': bool(score_indels),
                   'reporting_cutoff': int(reporting_cutoff),
                   'accession_id': accession_id}

    sys.stdout.write("Launching family report...\n")
    result = requests.post(url, auth=auth, data=json.dumps(url_payload))

    return result.json()


def main(argv):
    """Main function, creates a panel report.
    """
    if len(argv) < 3:
        sys.exit("Usage: python launch_family_report.py \
        <score_indels> <reporting_cutoff> <accession_id>")
    score_indels = argv[0]
    reporting_cutoff = argv[1]
    accession_id = argv[2]

    family_report_json = launch_family_report(
        score_indels,
        reporting_cutoff,
        accession_id)

    # Confirm launched report data
    sys.stdout.write("\n")

    if "clinical_report" not in family_report_json.keys():
        print family_report_json
        sys.exit("Failed to launch. Check report parameters for correctness.")
    clinical_report = family_report_json['clinical_report']
    sys.stdout.write('Launched Family Report:\n'
                     'id: {}\n'
                     'test_type: {}\n'
                     'accession_id: {}\n'
                     'created_on: {}\n'
                     'created_by: {}\n'
                     'filter_id: {}\n'
                     'filter_name: {}\n'
                     'panel_id: {}\n'
                     'workspace_id: {}\n'
                     'sample_collected_date: {}\n'
                     'sample_received_date: {}\n'
                     'include_cosmic: {}\n'
                     'vaast_report_id: {}\n'
                     'mother_genome_id: {}\n'
                     'father_genome_id: {}\n'
                     'genome_id: {}\n'
                     'status: {}\n'
                     'version: {}\n'
{'fraction_non_alphanumeric': 0.11225997045790251, 'fraction_numerical': 0.0013129821106187428, 'mean_word_length': 2.1331619537275066, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 9, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6706665', 'n_tokens_mistral': 1908, 'n_tokens_neox': 1815, 'n_words': 395}