Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(Major) Add autofil to the GitHub Actions workflow #1131

Closed
jfy133 opened this issue Dec 15, 2023 · 11 comments
Closed

(Major) Add autofil to the GitHub Actions workflow #1131

jfy133 opened this issue Dec 15, 2023 · 11 comments

Comments

@jfy133
Copy link
Member

jfy133 commented Dec 15, 2023

No description provided.

@maxibor
Copy link
Collaborator

maxibor commented Dec 18, 2023

@jfy133 This issue would be better in AncientMetagenomeDir :)

@jfy133
Copy link
Member Author

jfy133 commented Dec 18, 2023

Very good point 🤣. It came from the auto issue generation... Does the issue moving thing work?

@maxibor maxibor transferred this issue from SPAAM-community/amdirt Dec 18, 2023
@maxibor
Copy link
Collaborator

maxibor commented Dec 18, 2023

Apparently yes @jfy133

@jfy133
Copy link
Member Author

jfy133 commented Feb 12, 2024

My current idea:

  • Diff the table between master and the PR
  • Pull the new sample accession codes
  • Give to autofill

@jfy133
Copy link
Member Author

jfy133 commented Feb 12, 2024

Problems: diff doesn't work when other formatting changes have occured (or people fix upstream mistakes)

New approach, request bot to filter for the table and the new project ID e.g. @spaam-bot please autofill ancientsinglegenome-hostassociated majander2024

Then can use that info to filter the table to prepare the autofill command

@jfy133
Copy link
Member Author

jfy133 commented Feb 12, 2024

e.g.: grep 'Nishimura2024' ancientmetagenome-hostassociated/samples/ancientmetagenome-hostassociated_samples.tsv | rev | cut -f 1 | rev to get the new accessions

@jfy133
Copy link
Member Author

jfy133 commented Feb 12, 2024

X-ref for bot: https://stackoverflow.com/a/70244956

@jfy133
Copy link
Member Author

jfy133 commented Feb 12, 2024

Basic bash script:

#!/usr/bin/env bash

##
## AMDirT autofill wrapper for github actions
##
## Given a specified table and a project name, this script will
##
## 0. Check the specified table is valid name
## 1. filter the specified sample table for the given project name.
## 2. collect collect the sample accession IDs of that project
## 3. give error if there is no output (i.e., 0 accessions)
## 4. run AMDirT autofill with the collected accessions and the specified table name
##
## Copyright 2024 James Fellows Yates on behalf of the SPAAM community under MIT license

verbose=false

while getopts t:p:v flag; do
    case "${flag}" in
    v) verbose=true ;;
    t) table_name=${OPTARG} ;;
    p) project_name=${OPTARG} ;;
    esac
done

## TODO: check valid table name
if [ $verbose ]; then
    echo RUNNING: grep $project_name $table_name/samples/"$table_name"_samples.tsv "| rev | cut -f 1 | rev | tr '\n' ' '"
    echo ""
fi

hits=$(grep "$project_name" "$table_name"/samples/"$table_name"_samples.tsv | rev | cut -f 1 | rev | tr '\n' ' ')

if [ $verbose ]; then
    echo RUNNING: "${#hits} -eq 0"
    echo ""
fi

if [ ${#hits} -eq 0 ]; then
    echo 'Project name or sample accessions were not found in table. Please check project name input (-p).'
    exit 1
fi

if [ $verbose ]; then
    echo RUNNING: AMDirT autofill -n $table_name $hits -l TEMPLATE_$project_name_"$table_name"_libraries.tsv
    echo ""
fi

AMDirT autofill -n $table_name $hits -l TEMPLATE_$project_name_"$table_name"_libraries.tsv

@jfy133
Copy link
Member Author

jfy133 commented Feb 12, 2024

Better version, see: #1145

@jfy133
Copy link
Member Author

jfy133 commented Mar 15, 2024

TODO:
Parse the comment to extract the table name and project name

@jfy133
Copy link
Member Author

jfy133 commented Mar 26, 2024

Done in a variety of commits on master, the final being: 7d564e9

@jfy133 jfy133 closed this as completed Mar 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants