Skip to content

Commit

Permalink
new
Browse files Browse the repository at this point in the history
  • Loading branch information
builab committed Nov 10, 2023
1 parent ced4ed0 commit 18da330
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 2 deletions.
47 changes: 47 additions & 0 deletions filter_solution_list.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/usr/bin/python
# # -*- coding: utf-8 -*-

"""
@Authors Jerry Gao & Huy Bui
TODO May offer more option to filter
TODO Make the filter a common library and then reuse & rewrite some of the other programs
"""

import sys,os
import pandas as pd

def print_usage ():
print("usage: python filter_solution_list.py solutions_list minsize")
print("\tsolutions_list the revised csv file")
print("\tminsize minium size in amino acids")
print("eg: python filter_solution_list.py solutions_density1/fit_logs_revised.csv 100")
sys.exit()

def filter_csv(fitcsv, minsize):
''' This function is similar load_tophits_in_chimerax.py. Can we merge it or make a common one to share'''
if os.path.exists(fitcsv):
df = pd.read_csv(fitcsv, header = 0)
else:
print("WARNING: {:s} does not exist. Check again!".format(fitcsv))
exit(0)

df = df.loc[df['NoRes'] > minsize]
df_sub = df.reset_index(drop=True).copy()
#print(df_sub)
# Make index = 0 -> rank 1
return df_sub

if __name__ == "__main__":
if len(sys.argv) < 3:
print_usage()

fitcsv = sys.argv[1]
minsize = int(sys.argv[2])

print("Filtering {:s} with a minumum size of {:d} amino acids".format(fitcsv, minsize))
df = filter_csv(fitcsv, minsize)
print(df)
out_csv = fitcsv.replace('.csv', '_min{:d}.csv'.format(minsize))
df.to_csv(out_csv, index=False)
print("{:s} written!".format(out_csv))

3 changes: 1 addition & 2 deletions load_tophits_in_chimerax.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
@Authors Jerry Gao & Huy Bui
"""
# Usage
# python load_tophits_in_chimerax.py solutions_dir number_of_top_candidate_retained
# Operate from the main folder
# Load the top hits in ChimeraX

Expand All @@ -14,7 +13,7 @@

def print_usage ():
print("usage: python load_tophits_in_chimerax.py density solutions_dir number_of_top_hit minsize")
print("eg: ppython load_tophits_in_chimerax.py density.mrc solutions_dir 5 60")
print("eg: python load_tophits_in_chimerax.py density.mrc solutions_dir 5 60")
sys.exit()

def filter_csv(fitcsv, minsize):
Expand Down

0 comments on commit 18da330

Please sign in to comment.