Skip to content

Commit

Permalink
update sam file format
Browse files Browse the repository at this point in the history
  • Loading branch information
anegm98 committed May 26, 2020
1 parent e8ffe6c commit a01a93c
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 13 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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

Expand All @@ -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)
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

setup(
name='sternum',
version='1.0.0',
version='1.0.1',
package_dir={"": "src"},
install_requires=[],
setup_requires=[],
Expand Down
13 changes: 7 additions & 6 deletions src/reporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions tests/test_reporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__':
Expand Down

0 comments on commit a01a93c

Please # to comment.