-
Notifications
You must be signed in to change notification settings - Fork 0
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
Showing
1 changed file
with
55 additions
and
0 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,55 @@ | ||
#!/usr/bin/python3.5 | ||
import argparse | ||
import skbio | ||
|
||
|
||
def main(sampleFile, pos, sep=''): | ||
""" script to split a MSA by the organisms id """ | ||
seqInfo = bitk3.fastaReader(sampleFile) | ||
if sep == '': | ||
countsDict = bitk3.countFeaturesInHeaders(seqInfo[0], pos) | ||
else: | ||
countsDict = bitk3.countFeaturesInHeaders(seqInfo[0], pos, sep) | ||
|
||
keys = list(countsDict.keys()) | ||
keys.sort() | ||
|
||
for key in keys: | ||
print('{} : {}'.format(key, countsDict[key])) | ||
|
||
return countsDict | ||
|
||
if __name__ == "__main__": | ||
import bitk3 | ||
parser = argparse.ArgumentParser(prog='countFeatureInTag', | ||
usage='%(prog)s fasta_file.fa position', | ||
description='Count features in headers of \ | ||
fasta formated files') | ||
|
||
parser.add_argument('sampleFile', | ||
metavar='fasta_file.fa', | ||
type=str, | ||
help='Valid fasta formated file') | ||
|
||
parser.add_argument('pos', | ||
metavar='position', | ||
type=int, | ||
help='Integer of the position of the information \ | ||
to be counted. Positions are divided by default \ | ||
using "|" as separator') | ||
parser.add_argument('--sep', | ||
metavar='sep', | ||
type=str, | ||
help='Change the character that separates the \ | ||
fields in header', | ||
default='') | ||
|
||
args = parser.parse_args() | ||
|
||
sampleFile = args.sampleFile | ||
pos = args.pos | ||
sep = args.sep | ||
|
||
main(sampleFile, pos, sep) | ||
else: | ||
from bitk3 import bitk3 |