Skip to content

Commit

Permalink
Let's do this.
Browse files Browse the repository at this point in the history
  • Loading branch information
mdshw5 committed Dec 2, 2020
1 parent 77db60d commit bbf9b80
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 3 deletions.
25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Transcoorder

Convert SAM/BAM files with transcript coordinates to SAM files with genomic coordinates

```
$ transcoord -h
usage: transcoord [-h] [-o OUT] [-t TAG_NAME] [--debug] [--version] gtf bam fasta
positional arguments:
gtf GTF file containing transcripts
bam SAM or BAM files aligned to transcriptome
fasta FASTA format assembly coresponding to GTF
optional arguments:
-h, --help show this help message and exit
-o OUT, --out OUT output file for genomic SAM (default: stdout)
-t TAG_NAME, --tag-name TAG_NAME
SAM tag name for storing transcript identifier. default: ZT
--debug enable debugging
--version display version number
```

Note: This is an incomplete work in progress script and you shouldn't rely on its output. I
made this as a proof of concept, and never had time to finish. It currently runs very slowly
and only handles reads that are mapped entirely within an exon.
1 change: 0 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ def get_version(string):
install_requires=install_requires,
entry_points={'console_scripts': ['transcoord = transcoorder.cli:main']},
classifiers=[
"Development Status :: 5 - Production/Stable",
"License :: OSI Approved :: BSD License", "Environment :: Console",
"Intended Audience :: Science/Research", "Natural Language :: English",
"Operating System :: Unix", "Programming Language :: Python :: 3.5",
Expand Down
2 changes: 1 addition & 1 deletion transcoorder/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,6 @@ def transcript_sam_to_genomic_sam(sam, transcript, genome_offset,
for coord in transcript_coords:
if sam.pos <= coord[1] and sam.pos >= coord[0]:
# if read falls entirely within exon
if coord[1] - sam.pos > len(sam):
if coord[1] - sam.pos > len(sam.seq):
sam.pos += coord[0] + genome_offset
return sam
2 changes: 1 addition & 1 deletion transcoorder/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def main(ext_args=None):
transcript, genome_offset, transcript_coords = features
read = transcript_sam_to_genomic_sam(
read, transcript, genome_offset, transcript_coords)
if read:
if read is not None:
outfile.write(read)
pbar.update(1)

Expand Down

0 comments on commit bbf9b80

Please sign in to comment.