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

Add fasta format tidier? #22

Open
clairemcwhite opened this issue Feb 21, 2020 · 0 comments
Open

Add fasta format tidier? #22

clairemcwhite opened this issue Feb 21, 2020 · 0 comments

Comments

@clairemcwhite
Copy link

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

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

1 participant