Skip to content

Add fasta format tidier? #22

@clairemcwhite

Description

@clairemcwhite

I've been using a broom-style function to tidy seqinr::read.fasta objects. Would there be any interest in adding this to biobroom if I do a pull request?

read_fasta <- function(fasta_filename, annot = FALSE){
    fasta <- seqinr::read.fasta(fasta_filename, as.string = TRUE)

    # Convert seqinr SeqFastadna object to data.frame
    fasta_df <- fasta %>%
                   sapply(function(x){x[1:length(x)]}) %>%
                   as.data.frame %>%
                   broom::fix_data_frame(newcol = "ID", newnames = "Sequence")

    if(annot == TRUE){
        annot_df <- getAnnot(fasta) %>%
                         sapply(function(x){x[1:length(x)]}) %>%
                         as.data.frame() %>%
                         broom::fix_data_frame(newnames = "Annot")

        fasta_df <- cbind(fasta_df, annot_df)
    }
    return(fasta_df)
}
read_fasta('https://www.uniprot.org/uniprot/?query=PGH1&format=fasta&limit=10')

https://gist.github.com/clairemcwhite/a5e889f6192a664be45c0226d0ab5813

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions