From 311b01bf9b079340763a44a2ac1f7913a0f87305 Mon Sep 17 00:00:00 2001 From: eliko1991 Date: Thu, 28 Mar 2024 16:46:12 -0400 Subject: [PATCH] Working deps (#6) * non breaking dependenciesgit statusgit statusgit statusgit statusgit statusgit status * update logic to accomondate for multiple analysis assemblies for the same experiment * update alhenaloader and isabl cli deps, and remove the rest --------- Co-authored-by: eliko1991 Co-authored-by: eliko1991 Co-authored-by: SVC_shahs3_bot --- README.md | 27 +++---------------- alhena_igo/cli.py | 15 +++++------ alhena_igo/isabl.py | 66 +++++++++++++++++++++++++++++++++++++-------- setup.py | 6 ++--- 4 files changed, 67 insertions(+), 47 deletions(-) diff --git a/README.md b/README.md index 9a40b83..32d4b3f 100644 --- a/README.md +++ b/README.md @@ -7,35 +7,16 @@ This extends the existing alhenaloader module by providing methods that'll pull ## Install -You can install directly from pip: - -``` -pip install -e git+https://github.com/shahcompbio/alhena_igo.git#egg=alhena_igo -``` - -Or - -Clone the repo ``` git clone https://github.com/shahcompbio/alhena_igo.git -``` -In that directory, create a new venv +conda create -n alhena python=3.9 -``` -python3 -m venv venv -``` - -Then install the requirements - -``` -pip install -r requirements.txt -``` +source alhena -Then install the loader: +cd alhena_igo -``` make build ``` @@ -99,4 +80,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. \ No newline at end of file +SOFTWARE. diff --git a/alhena_igo/cli.py b/alhena_igo/cli.py index 91e8904..142bb8b 100644 --- a/alhena_igo/cli.py +++ b/alhena_igo/cli.py @@ -96,20 +96,19 @@ def clean(info: Info, analysis: str): @cli.command() -@click.option('--id', help="Aliquot ID", required=True) +@click.option('--analysis_id', help="MONDRIAN-HMMCOPY or SCDNA-ANNOTATION analysis primary key", required=True) @click.option('--project', 'projects', multiple=True, default=["DLP"], help="Projects to load analysis into") @click.option('--framework', type=click.Choice(['scp', 'mondrian']), help="Framework: scp or mondrian") @click.option('--version', help="Isabl app version to load", required=True) @pass_info -def load(info: Info, id: str, projects: List[str], framework: str, version: str): - analysis_id = alhena_igo.isabl.get_id(id, framework, version) +def load(info: Info, analysis_id: str, projects: List[str], framework: str, version: str): click.echo(f'Loading as ID {analysis_id}') if framework == 'scp': - [alignment, hmmcopy, annotation] = alhena_igo.isabl.get_directories(id, framework, version) + [alignment, hmmcopy, annotation] = alhena_igo.isabl.get_directories(analysis_id, framework, version) data = load_qc_results(alignment, hmmcopy, annotation) elif framework == 'mondrian': - [alignment, hmmcopy] = alhena_igo.isabl.get_directories(id, framework, version) + [alignment, hmmcopy] = alhena_igo.isabl.get_directories(analysis_id, framework, version) data = load_qc_results(alignment, hmmcopy) else: raise Exception(f"Unknown framework option '{framework}'") @@ -137,15 +136,13 @@ def load_project(info: Info, alhena: List[str], isabl: str, framework:str, versi for analysis_id in diff: alhenaloader.clean_analysis(analysis_id, info.es) - aliquot_id = [record['aliquot'] for record in isabl_records if record['dashboard_id'] == analysis_id][0] - click.echo(f'Loading as ID {analysis_id}') if framework == 'mondrian': - [alignment, hmmcopy] = alhena_igo.isabl.get_directories(aliquot_id, framework, version) + [alignment, hmmcopy] = alhena_igo.isabl.get_directories(analysis_id, framework, version) data = load_qc_results(alignment, hmmcopy) elif framework == 'scp': - [alignment, hmmcopy, annotation] = alhena_igo.isabl.get_directories(aliquot_id, framework, version) + [alignment, hmmcopy, annotation] = alhena_igo.isabl.get_directories(analysis_id, framework, version) data = load_qc_results(alignment, hmmcopy, annotation) else: raise Exception(f"Unknown framework '{framework}'.") diff --git a/alhena_igo/isabl.py b/alhena_igo/isabl.py index 439a29c..61cec4c 100644 --- a/alhena_igo/isabl.py +++ b/alhena_igo/isabl.py @@ -42,19 +42,63 @@ # es.add_analysis_to_projects(analysis_id, projects) -def get_directories(target_aliquot: str, framework: str, version: str): - """Return alignment, hmmcopy, and annotation directory paths based off aliquot ID""" - experiment = ii.get_experiments(aliquot_id=target_aliquot)[0] - +def get_analysis_filtered_by_assembly(experiment_sys_id, app_name, assembly): + """ + Assembly filter does not work in Isabl for some reason, so fitlering in the + following manner. + """ + analyses = ii.get_analyses( + application__name=app_name, + targets__system_id=experiment_sys_id, + ) + + for analysis in analyses: + if analysis.application.assembly.name == assembly: + return analysis + + raise Exception(f"Unable to retrieve analyses for {experiment_sys_id} - {app_name} - {assembly}") + + +def get_directories(analysis_pk: str, framework: str, version: str): + """ + Return QC results for Mondrian or SCP based off MONDRIAN-HMMCOPY or SCDNA-ANNOTATION + analysis primary key. + """ + if framework == 'mondrian': - alignment = get_analysis('MONDRIAN-ALIGNMENT', version, experiment.system_id) - hmmcopy = get_analysis('MONDRIAN-HMMCOPY', version, experiment.system_id) - return [alignment["storage_url"], hmmcopy["storage_url"]] + hmmcopy = ii.get_analyses(pk=analysis_pk, application__name='MONDRIAN-HMMCOPY') + assert len(hmmcopy) == 1 + + assembly = hmmcopy[0].application.assembly.name + + alignment = get_analysis_filtered_by_assembly( + hmmcopy[0].targets[0].system_id, + 'MONDRIAN-ALIGNMENT', + assembly + ) + + return [alignment.storage_url, hmmcopy[0].storage_url] + elif framework == 'scp': - alignment = get_analysis('SCDNA-ALIGNMENT', version, experiment.system_id) - hmmcopy = get_analysis('SCDNA-HMMCOPY', version, experiment.system_id) - annotation = get_analysis('SCDNA-ANNOTATION', version, experiment.system_id) - return [alignment["storage_url"], hmmcopy["storage_url"], annotation["storage_url"]] + annotation = ii.get_analyses(pk=analysis_pk, application__name='SCDNA-ANNOTATION') + assert len(annotation) == 1 + + assembly = annotation[0].application.assembly.name + + hmmcopy = get_analysis_filtered_by_assembly( + annotation[0].targets[0].system_id, + 'SCDNA-HMMCOPY', + assembly + ) + + alignment = get_analysis_filtered_by_assembly( + annotation[0].targets[0].system_id, + 'SCDNA-ALIGNMENT', + assembly + ) + + return [alignment.storage_url, hmmcopy.storage_url, annotation[0].storage_url] + else: raise Exception(f"Unknown framework '{framework}'") diff --git a/setup.py b/setup.py index 4c85e8a..6ccfec3 100644 --- a/setup.py +++ b/setup.py @@ -49,10 +49,8 @@ version=version, install_requires=[ # Include dependencies here - 'click>=7.0,<8', - "alhenaloader @ git+https://github.com/shahcompbio/alhenaloader.git@main#egg=alhenaloader", - "scgenome @ git+https://github.com/shahcompbio/scgenome.git@master#egg=scgenome", - "isabl_cli @ git+https://github.com/shahcompbio/isabl_cli.git#egg=isabl_cli" + "alhenaloader @ git+https://github.com/shahcompbio/alhenaloader.git@v1.0.6#egg=alhenaloader", + "isabl_cli @ git+https://github.com/papaemmelab/isabl_cli.git#egg=isabl_cli" ], entry_points=""" [console_scripts]