Last active
February 21, 2020 20:49
-
-
Save clairemcwhite/a5e889f6192a664be45c0226d0ab5813 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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('human_uniprot-proteome_human_reviewed.fasta') | |
read_fasta('https://www.uniprot.org/uniprot/?query=PGH1&format=fasta&limit=10') | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Tidy a fasta file
Compare to the unwrapped read.fasta output