-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7274b61
commit 1b94999
Showing
7 changed files
with
114 additions
and
285 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
using System; | ||
using System.IO; | ||
using System.IO.Compression; | ||
|
||
namespace Ovation.FasterQC.Net | ||
{ | ||
public abstract class AbstractReader : ISequenceReader | ||
{ | ||
private readonly FileStream inputStream; | ||
|
||
private readonly GZipStream? gzipStream; | ||
|
||
protected readonly BufferedStream bufferedStream; | ||
|
||
protected readonly int bufferSize = 128 * 1024; | ||
|
||
private bool disposedValue; | ||
|
||
protected ulong sequencesRead = 0; | ||
|
||
public ulong SequencesRead => sequencesRead; | ||
|
||
public double ApproximateCompletion => | ||
100.0 * inputStream.Position / inputStream.Length; | ||
|
||
public AbstractReader(string filename, bool gzipped = true) | ||
{ | ||
var fileStreamOptions = new FileStreamOptions() | ||
{ | ||
Mode = FileMode.Open, | ||
BufferSize = bufferSize, | ||
}; | ||
|
||
if (gzipped == true) | ||
{ | ||
inputStream = File.Open(filename, fileStreamOptions); | ||
gzipStream = new GZipStream(inputStream, CompressionMode.Decompress); | ||
bufferedStream = new BufferedStream(gzipStream, bufferSize); | ||
} | ||
else | ||
{ | ||
inputStream = File.Open(filename, fileStreamOptions); | ||
bufferedStream = new BufferedStream(inputStream, bufferSize); | ||
} | ||
} | ||
|
||
public abstract bool ReadSequence(out Sequence? sequence); | ||
|
||
protected virtual void Dispose(bool disposing) | ||
{ | ||
if (!disposedValue) | ||
{ | ||
if (disposing) | ||
{ | ||
bufferedStream?.Dispose(); | ||
gzipStream?.Dispose(); | ||
inputStream?.Dispose(); | ||
} | ||
|
||
disposedValue = true; | ||
} | ||
} | ||
|
||
public void Dispose() | ||
{ | ||
Dispose(true); | ||
GC.SuppressFinalize(this); | ||
} | ||
} | ||
} |
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 was deleted.
Oops, something went wrong.
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
Oops, something went wrong.