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 support for load_genomic_breaks() function #31

Merged
merged 2 commits into from
Jul 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 19 additions & 7 deletions R/load_genomic_breaks.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
#'
#' @param file Path to a file in GFF3 or MAF format. The file can be compressed
#' with _gzip_.
#' @param target_bsgenome A `BSgenome` object representing the _target_ genome.
#' @param query_bsgenome A `BSgenome` object representing the _query_ genome.
#' @param target_bsgenome A `BSgenome` object or path to a FASTA file representing the _target_ genome.
#' @param query_bsgenome A `BSgenome` object or path to a FASTA file representing the _query_ genome.
#' @param sort Returns the object sorted, ignoring strand information.
#' @param type In GFF3 files, _Sequence Ontology_ term representing an alignment
#' block (default: `match_part`).
Expand Down Expand Up @@ -78,17 +78,29 @@ load_genomic_breaks_GFF <- function (
type = "match_part")
{
gb <- import.gff3(file)
if (! is.null(target_bsgenome))
gb <- GRanges(gb, seqinfo = seqinfo(target_bsgenome))
if (!is.null(target_bsgenome)) {
if (is.character(target_bsgenome)) {
target_seqinfo <- seqinfo(readDNAStringSet(target_bsgenome))
} else {
target_seqinfo <- seqinfo(target_bsgenome)
}
gb <- GRanges(gb, seqinfo = target_seqinfo)
}
# Discard cross_genome_match parent (used for block display in Zenbu)
gb <- gb[gb$type == type]
# Discard unused information
gb$phase <- gb$Parent <- gb$Target <- gb$ID <- gb$source <- gb$type <- NULL
# Convert query coordinates to GRanges
if (! is.null(query_bsgenome))
gb$query <- GRanges(gb$Name, seqinfo = seqinfo(query_bsgenome))
else
if (!is.null(query_bsgenome)) {
if (is.character(query_bsgenome)) {
query_seqinfo <- seqinfo(readDNAStringSet(query_bsgenome))
} else {
query_seqinfo <- seqinfo(query_bsgenome)
}
gb$query <- GRanges(gb$Name, seqinfo = query_seqinfo)
} else {
gb$query <- GRanges(gb$Name)
}
gb$Name <- NULL
if (sort) gb <- sort(gb, ignore.strand = TRUE)
as(gb, "GBreaks")
Expand Down
Loading