Commit e2b4e53b authored by Aaron Quinlan's avatar Aaron Quinlan
Browse files

Merge pull request #242 from gtamazian/getfasta-fixes

Getfasta fixes
parents 5827f9c1 0b736751
......@@ -244,7 +244,14 @@ void FastaReference::open(string reffilename, bool usemmap, bool useFullHeader)
struct stat stFileInfo;
string indexFileName = filename + index->indexFileExtension();
// if we can find an index file, use it
if(stat(indexFileName.c_str(), &stFileInfo) == 0) {
if(stat(indexFileName.c_str(), &stFileInfo) == 0) {
// check if the index file is older than the FASTA file
struct stat index_attrib, fasta_attrib;
stat(indexFileName.c_str(), &index_attrib);
stat(reffilename.c_str(), &fasta_attrib);
if (fasta_attrib.st_mtime > index_attrib.st_mtime) {
cerr << "Warning: the index file is older than the FASTA file." << endl;
}
index->readIndexFile(indexFileName);
} else { // otherwise, read the reference and generate the index file in the cwd
cerr << "index file " << indexFileName << " not found, generating..." << endl;
......
......@@ -88,7 +88,7 @@ AGCTYRWSKMDVHBXN
agctyrwskmdvhbxn" > exp
$BT getfasta -fi test.iupac.fa -bed test.iupac.bed -fo - > obs
check obs exp
rm obs exp
rm obs exp test.iupac.fa.fai
# test IUPAC revcomp
......@@ -100,4 +100,23 @@ NXVDBHKMSWYRAGCT
nxvdbhkmswyragct" > exp
$BT getfasta -fi test.iupac.fa -bed test.iupac.bed -s -fo - > obs
check obs exp
rm obs exp
rm obs exp test.iupac.fa.fai
# test the warning about an outdated FASTA index file
echo " getfasta.t10...\c"
echo \
">chr1
cggggggggg
>chr2
AAATTTTTTTTTT" > test.fa
# create an index file
echo -e "chr2\t2\t10" | $BT getfasta -fi test.fa -bed - -fo - > /dev/null
# modify the FASTA file in a second
sleep 1
touch test.fa
echo -e "chr2\t2\t10" | $BT getfasta -fi test.fa -bed - -fo - \
> /dev/null 2> obs
echo "Warning: the index file is older than the FASTA file." > exp
check obs exp
rm obs exp test.fa test.fa.fai
1 0 16 1 1000 -
2 0 16 1 1000 -
>1
AGCTYRWSKMDVHBXNACGT
>2
agctyrwskmdvhbxnacgt
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment