Skip to content

Commit

Permalink
Working deps (#6)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
Co-authored-by: eliko1991 <[email protected]>
Co-authored-by: SVC_shahs3_bot <[email protected]>
  • Loading branch information
4 people authored Mar 28, 2024
1 parent d046f7e commit 311b01b
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 47 deletions.
27 changes: 4 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```

Expand Down Expand Up @@ -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.
SOFTWARE.
15 changes: 6 additions & 9 deletions alhena_igo/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}'")
Expand Down Expand Up @@ -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}'.")
Expand Down
66 changes: 55 additions & 11 deletions alhena_igo/isabl.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}'")

Expand Down
6 changes: 2 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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/[email protected]#egg=alhenaloader",
"isabl_cli @ git+https://github.com/papaemmelab/isabl_cli.git#egg=isabl_cli"
],
entry_points="""
[console_scripts]
Expand Down

0 comments on commit 311b01b

Please sign in to comment.