-
Notifications
You must be signed in to change notification settings - Fork 311
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
[ADAM-1481] Refactor ADAMContext loadXxx methods for consistency #1487
Merged
Merged
Changes from 1 commit
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
b0505c4
Refactor ADAMContext loadXxx methods for consistency, commit 1 of sev…
heuermh 7e6bca7
Format long lines
heuermh f894f8a
Minor doc fixes
heuermh 6c988b7
Add FileExtensions, confirm pathName doc strings
heuermh c7814c9
Missed merge flotsam
heuermh f3d1d3c
Moar doc fixes, add'l load methods
heuermh b021e2c
Use compression codecs from Hadoop configuration instead of hardcoded…
heuermh 9b13e6e
Document compressed file support via Hadoop compression codecs.
heuermh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
329 changes: 165 additions & 164 deletions
329
adam-core/src/main/scala/org/bdgenomics/adam/rdd/ADAMContext.scala
Large diffs are not rendered by default.
Oops, something went wrong.
145 changes: 145 additions & 0 deletions
145
adam-core/src/main/scala/org/bdgenomics/adam/util/FileExtensions.scala
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,145 @@ | ||
/** | ||
* Licensed to Big Data Genomics (BDG) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The BDG licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.bdgenomics.adam.util | ||
|
||
/** | ||
* Match path names to file extensions. | ||
*/ | ||
object FileExtensions { | ||
|
||
/** | ||
* @param pathName The path name to match. | ||
* @return Returns true if the path name matches a 2bit format file extension. | ||
*/ | ||
private[adam] def is2BitExt(pathName: String): Boolean = { | ||
pathName.endsWith(".2bit") | ||
} | ||
|
||
/** | ||
* @param pathName The path name to match. | ||
* @return Returns true if the path name matches a BAM/CRAM/SAM format file extension. | ||
*/ | ||
private[adam] def isBamExt(pathName: String): Boolean = { | ||
pathName.endsWith(".bam") || | ||
pathName.endsWith(".cram") || | ||
pathName.endsWith(".sam") | ||
} | ||
|
||
/** | ||
* @param pathName The path name to match. | ||
* @return Returns true if the path name matches a BED6/12 format file extension. | ||
*/ | ||
private[adam] def isBedExt(pathName: String): Boolean = { | ||
pathName.endsWith(".bed") || | ||
pathName.endsWith(".bed.gz") || | ||
pathName.endsWith(".bed.bz2") | ||
} | ||
|
||
/** | ||
* @param pathName The path name to match. | ||
* @return Returns true if the path name matches a FASTA format file extension. | ||
*/ | ||
private[adam] def isFastaExt(pathName: String): Boolean = { | ||
pathName.endsWith(".fa") || | ||
pathName.endsWith(".fa.gz") || | ||
pathName.endsWith(".fa.bz2") || | ||
pathName.endsWith(".fasta") || | ||
pathName.endsWith(".fasta.gz") || | ||
pathName.endsWith(".fasta.bz2") | ||
} | ||
|
||
/** | ||
* @param pathName The path name to match. | ||
* @return Returns true if the path name matches a FASTQ format file extension. | ||
*/ | ||
private[adam] def isFastqExt(pathName: String): Boolean = { | ||
pathName.endsWith(".fq") || | ||
pathName.endsWith(".fq.gz") || | ||
pathName.endsWith(".fq.bz2") || | ||
pathName.endsWith(".fastq") || | ||
pathName.endsWith(".fastq.gz") || | ||
pathName.endsWith(".fastq.bz2") | ||
} | ||
|
||
/** | ||
* @param pathName The path name to match. | ||
* @return Returns true if the path name matches a GFF3 format file extension. | ||
*/ | ||
private[adam] def isGff3Ext(pathName: String): Boolean = { | ||
pathName.endsWith(".gff3") || | ||
pathName.endsWith(".gff3.gz") || | ||
pathName.endsWith(".gff3.bz2") | ||
} | ||
|
||
/** | ||
* @param pathName The path name to match. | ||
* @return Returns true if the path name matches a GFF2/GTF format file extension. | ||
*/ | ||
private[adam] def isGtfExt(pathName: String): Boolean = { | ||
pathName.endsWith(".gff") || | ||
pathName.endsWith(".gff.gz") || | ||
pathName.endsWith(".gff.bz2") || | ||
pathName.endsWith(".gtf") || | ||
pathName.endsWith(".gtf.gz") || | ||
pathName.endsWith(".gtf.bz2") | ||
} | ||
|
||
/** | ||
* @param pathName The path name to match. | ||
* @return Returns true if the path name matches an interleaved FASTQ format file extension. | ||
*/ | ||
private[adam] def isInterleavedFastqExt(pathName: String): Boolean = { | ||
pathName.endsWith(".ifq") || | ||
pathName.endsWith(".ifq.gz") || | ||
pathName.endsWith(".ifq.bz2") | ||
} | ||
|
||
/** | ||
* @param pathName The path name to match. | ||
* @return Returns true if the path name matches an IntervalList format file extension. | ||
*/ | ||
private[adam] def isIntervalListExt(pathName: String): Boolean = { | ||
pathName.endsWith(".interval_list") || | ||
pathName.endsWith(".interval_list.gz") || | ||
pathName.endsWith(".interval_list.bz2") | ||
} | ||
|
||
/** | ||
* @param pathName The path name to match. | ||
* @return Returns true if the path name matches a NarrowPeak format file extension. | ||
*/ | ||
private[adam] def isNarrowPeakExt(pathName: String): Boolean = { | ||
pathName.endsWith(".narrowpeak") || | ||
pathName.endsWith(".narrowpeak.gz") || | ||
pathName.endsWith(".narrowpeak.bz2") || | ||
pathName.endsWith(".narrowPeak") || | ||
pathName.endsWith(".narrowPeak.gz") || | ||
pathName.endsWith(".narrowPeak.bz2") | ||
} | ||
|
||
/** | ||
* @param pathName The path name to match. | ||
* @return Returns true if the path name matches a VCF format file extension. | ||
*/ | ||
private[adam] def isVcfExt(pathName: String): Boolean = { | ||
pathName.endsWith(".vcf") || | ||
pathName.endsWith(".vcf.gz") || | ||
pathName.endsWith(".vcf.bgzf") || | ||
pathName.endsWith(".vcf.bgz") | ||
} | ||
} |
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As an aside, for all of the compressed file format checks, we should use Hadoop's CompressionCodecFactory to check if the path is a compressed file. This allows users to swap in additional compression codecs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, I suppose we could do an isCompressed check in
ADAMContext
, since it has access to the Hadoop configuration, then trim off the extension before checking withFileExtensions