Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion BLAST/configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"""Write and parse configuration files for BLASTn"""

import sys
if sys.version_info.major is not 3:
if sys.version_info.major != 3:
sys.exit("Please use Python 3 for this module: " + __name__)

import configparser
Expand Down
2 changes: 1 addition & 1 deletion BLAST/runblastn.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env python3

import sys
if sys.version_info.major is not 3:
if sys.version_info.major != 3:
sys.exit("Please use Python 3 for this module: " + __name__)

import os
Expand Down
33 changes: 21 additions & 12 deletions Objects/alignment.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
#!/usr/bin/env python3

import sys
if sys.version_info.major is not 3:

if sys.version_info.major != 3:
sys.exit("Please use Python 3 for this module: " + __name__)

import re


# A class definition for a SAM alignment
class Alignment(object):
"""A class to hold a SAM Alignment
Expand All @@ -16,27 +18,35 @@ class Alignment(object):
1-based leftmost mapping position
Cigar string
"""
_CIGAR = re.compile(u'([0-9]+[A-Z]+)') # Regex to break the CIGAR string into component codes using re.findall()

_CIGAR = re.compile(
"([0-9]+[A-Z]+)"
) # Regex to break the CIGAR string into component codes using re.findall()

def __init__(self, line):
try:
assert isinstance(line, str)
except AssertionError:
raise TypeError
# There's only some information that we need for our alignment, everything else is forgotten
split_line = line.strip().split() # Remove leading and trailing whitespace, then split the line by column
self._qname = split_line[0] # First column in a SAM file
self._flag = int(split_line[1]) # Second column
self._rname = split_line[2] # Third column
self._pos = int(split_line[3]) # Fourth column, should be an int
self._cigar = self._CIGAR.findall(split_line[5]) # Sixth column, after breaking up the CIGAR string into a list of component codes
split_line = (
line.strip().split()
) # Remove leading and trailing whitespace, then split the line by column
self._qname = split_line[0] # First column in a SAM file
self._flag = int(split_line[1]) # Second column
self._rname = split_line[2] # Third column
self._pos = int(split_line[3]) # Fourth column, should be an int
self._cigar = self._CIGAR.findall(
split_line[5]
) # Sixth column, after breaking up the CIGAR string into a list of component codes

def __repr__(self):
return self._rname + ':' + self._qname
return self._rname + ":" + self._qname

def get_rc(self):
"""Check to see if we're reverse complementing our sequence"""
# If the 16th bit is set, it's reverse complement
return self._flag is 16
return self._flag == 16

def get_name(self):
"""Get the alignment name"""
Expand All @@ -56,5 +66,4 @@ def get_cigar(self):

def check_flag(self):
"""Make sure we don't have extraneous alignments"""
return self._flag is 0 or self._flag is 16

return self._flag == 0 or self._flag == 16
Loading