forked from flystar233/pyscript-bio
-
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
1 parent
4698211
commit c19c22f
Showing
1 changed file
with
21 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,21 @@ | ||
#!/usr/bin/env python3 | ||
# -*- coding: utf-8 -*- | ||
|
||
''' | ||
__author__ = 'xutengfei' | ||
__author_email__ = '[email protected] | ||
Fuc: Compute the character with the highest frequency in the string. | ||
''' | ||
|
||
import sys | ||
def max_word(in_file,out_file): | ||
|
||
with open(in_file,'r') as IN1, open(out_file,'w') as OUT: | ||
data = IN1.readlines() | ||
for i in data: | ||
text = i.upper() | ||
OUT.write(max(text, key=text.count)+"\t"+str(text.count(max(text, key=text.count))/(len(text)-1))+"\n") | ||
if (len(sys.argv)==3): | ||
max_word(sys.argv[1],sys.argv[2]) | ||
else: | ||
print("Usage: python in_file out_file") |