From a01a93cda4c052feae5059a82e8ab4b6eee68fb4 Mon Sep 17 00:00:00 2001 From: anegm98 Date: Tue, 26 May 2020 08:07:23 +0200 Subject: [PATCH] update sam file format --- README.md | 6 +++--- setup.py | 2 +- src/reporter.py | 13 +++++++------ tests/test_reporter.py | 6 +++--- 4 files changed, 14 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index a1554c2..d4b9555 100644 --- a/README.md +++ b/README.md @@ -65,7 +65,7 @@ how many sequence reads to be loaded into memory per iteration to be mapped ### Output: - #### pseudo SAM file `-o` str() -a file containing only read name, position, and read sequence per match +a file containing only read name, reference name, position, and read sequence per match ## Getting started @@ -75,7 +75,7 @@ a file containing only read name, position, and read sequence per match - In your command line environment: - pip install path/to/sternum-x.x.x-py2.py3-none-any.whl + pip install path/to/sternum-x.x.x-py3-none-any.whl ### Run an example @@ -84,6 +84,6 @@ a file containing only read name, position, and read sequence per match sternum -m method -r path/to/reference.fastx -s path/to/sequence.fastx -k kmerSize -p minPercentage -c minKcount -b batchSize -o path/to/myfirstmap - this file will be genrated: -path/to/myfirstmap_\$m_\$sequenceID.pSAM +path/to/myfirstmap_\$m_\$sequenceID.sam - you can try with files in [sternum/data](https://github.com/anegm98/Sternum/tree/master/data) diff --git a/setup.py b/setup.py index fc401eb..3e8a7b7 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ setup( name='sternum', - version='1.0.0', + version='1.0.1', package_dir={"": "src"}, install_requires=[], setup_requires=[], diff --git a/src/reporter.py b/src/reporter.py index fc91c03..14af6e5 100644 --- a/src/reporter.py +++ b/src/reporter.py @@ -39,16 +39,17 @@ def report(self, filePrefix=""): """ readName = list(self.sequence.keys())[0] readName = readName[: readName.find(".")] - file = open(filePrefix+readName+".pSAM", 'w') + file = open(filePrefix+readName+".sam", 'w') lines = [] for readID in self.matching: for refID in self.matching[readID]: for matchInst in self.matching[readID][refID]: - line = readID + '\tNone' - line += '\t' + str(matchInst[0][0] + 1) - line += ' ' + str(matchInst[1] + 1) - line += '\tNone' + '\tNone' + '\tNone' - line += '\t' + self.sequence[readID] + '\n' + line = readID + '\t0' + line += '\t' + refID + line += '\t' + str(matchInst[1] + 1) + line += '\t255' + '\t*' + '\t*' + '\t0' + line += '\t' + self.sequence[readID] + line += '\t*' + '\n' lines.append(line) lines[-1] = lines[-1].rstrip('\n') file.writelines(lines) diff --git a/tests/test_reporter.py b/tests/test_reporter.py index f9b2bb1..599f828 100644 --- a/tests/test_reporter.py +++ b/tests/test_reporter.py @@ -12,12 +12,12 @@ def test_file_maker(self): """ sternum = initiate_case(-1) reporter(sternum) - file = open("ERR1293055.pSAM") + file = open("ERR1293055.sam") line = file.readline() file.close() - self.assertIn("ERR1293055.19\tNone\t14 728\tNone\tNone\tNone\ + self.assertIn("ERR1293055.19\t0\tKR233687.2.1\t728\t255\t*\t*\t0\ \tCTGGCGGAGAAGTGAGAAAT", line) - os.remove("ERR1293055.pSAM") + os.remove("ERR1293055.sam") if __name__ == '__main__':