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

enable Usage.init_artifact to accept kwargs that are passed to the factory #763

Open
gregcaporaso opened this issue Apr 8, 2024 · 0 comments
Assignees

Comments

@gregcaporaso
Copy link
Member

gregcaporaso commented Apr 8, 2024

Is there a technical reason why Usage.init_artifact doesn't accept kwargs that can be passed through to the factory function?

If not that would be convenient to enable, to support factory functions like the following:

def dna_artifact_factory(sequence_id: str, sequence: str):
    seq = skbio.DNA(sequence, metadata={id: sequence_id})
    with tempfile.NamedTemporaryFile() as f:
        # write our skbio.DNA object to file in fasta format (the default)
        seq.write(f)
        # reset to the beginning of the file
        f.seek(0)
        # instantiate our format object with the fasta
        ff = SingleRecordDNAFASTAFormat(f.name, mode='r')
        # return the sequence packaged in a "SingleDNASequence" qiime2.Artifact
        return qiime2.Artifact.import_data("SingleDNASequence", ff)

def nw_align_example_1(use):
    seq1 = use.init_artifact('seq1', dna_artifact_factory, "seq1", "ACGGTTAA")
    seq2 = use.init_artifact('seq2', dna_artifact_factory, "seq2", "ATTGTAA")
...

I planned to do this while working on usage example content for Developing with QIIME 2, but remembered that I need to define a factory function per input as it stands right now.

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