-
Notifications
You must be signed in to change notification settings - Fork 57
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
3 changed files
with
46 additions
and
28 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 |
---|---|---|
|
@@ -6,31 +6,46 @@ | |
from ldpred import LDpred_inf | ||
from ldpred import LD_pruning_thres | ||
from ldpred import validate | ||
from ldpred import reporting | ||
|
||
import sys | ||
import textwrap | ||
|
||
__version__ = '1.0.4' | ||
__version__ = '1.0.5' | ||
__date__ = '15 March 2019' | ||
|
||
|
||
parser = argparse.ArgumentParser(prog='LDpred', | ||
formatter_class=argparse.RawDescriptionHelpFormatter, | ||
description=textwrap.dedent("""\ | ||
\033[96mLDpred v. 1.0.2\033[0m | ||
-------------------------------------------------------------------------------------- | ||
Thank you for using\033[1m LDpred\033[0m! | ||
title = '\033[96mLDpred v. %s\033[0m'%__version__ | ||
title_len= len(title)-9 | ||
num_dashes = reporting.window_length-title_len-2 | ||
left_dashes = '='*int(num_dashes/2) | ||
right_dashes = '='*int(num_dashes/2+num_dashes%2) | ||
title_string = '\n'+left_dashes + ' '+title+' '+right_dashes +'\n' | ||
description_string = """ | ||
Typicial workflow: | ||
1. Use\033[1m LDpred coord\033[0m to parse summary statistics and genotypes and coordinate data. | ||
See LDpred coord --help for further usage description and options. | ||
1. Use\033[1m LDpred coord\033[0m to parse summary statistics and genotypes | ||
and coordinate data. See LDpred coord --help for further usage | ||
description and options. | ||
2. Use\033[1m LDpred gibbs|inf|p+t\033[0m to obtain SNP weights for polygenic scoring using one or | ||
more methods. See LDpred gibbs|inf|p+t --help for further usage description and options. | ||
2. Use\033[1m LDpred gibbs|inf|p+t\033[0m to obtain SNP weights for polygenic | ||
scoring using one or more methods. See LDpred gibbs|inf|p+t --help for | ||
further usage description and options. | ||
3. Use\033[1m LDpred score\033[0m to calculate polygenic scores using SNP weights from previous | ||
step. See LDpred score --help for further usage description and options. | ||
3. Use\033[1m LDpred score\033[0m to calculate polygenic scores using SNP | ||
weights from previous step. See LDpred score --help for further usage | ||
description and options. | ||
2019 (c) Bjarni J Vilhjalmsson: [email protected] | ||
""")) | ||
Thank you for using\033[1m LDpred\033[0m! | ||
%s | ||
(c) Bjarni J Vilhjalmsson: [email protected] | ||
"""%(__date__) | ||
description_string += '='*reporting.window_length | ||
|
||
parser = argparse.ArgumentParser(prog='LDpred', | ||
formatter_class=argparse.RawDescriptionHelpFormatter, | ||
description=textwrap.dedent(description_string)) | ||
|
||
|
||
subparsers = parser.add_subparsers(help='Select ldpred action among the following options: ', dest='ldpred_action') | ||
parser_coord = subparsers.add_parser('coord', help='Parse and coordinate summary statistics and genotypes.') | ||
|
@@ -246,8 +261,8 @@ | |
|
||
|
||
def main(): | ||
print(title_string) | ||
if len(sys.argv)==1: | ||
print ('ERROR: No options provided.\n') | ||
parser.print_help(sys.stderr) | ||
sys.exit(1) | ||
parameters = parser.parse_args() | ||
|
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
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 |
---|---|---|
@@ -1,34 +1,37 @@ | ||
""" | ||
Bunch of functions for beautifying output. | ||
""" | ||
window_length = 80 | ||
name_length = 50 | ||
|
||
def print_summary(summary_dict, title, log_file=None): | ||
print('') | ||
title_len= len(title) | ||
num_dashes = 80-title_len-2 | ||
num_dashes = window_length-title_len-2 | ||
left_dashes = '='*int(num_dashes/2) | ||
right_dashes = '='*int(num_dashes/2+num_dashes%2) | ||
val_length=window_length-name_length | ||
|
||
print( left_dashes + ' '+title+' '+right_dashes) | ||
for k in sorted(summary_dict.keys()): | ||
sd = summary_dict[k] | ||
if sd['name']=='dash': | ||
if 'value' not in sd: | ||
print ('-' * 80) | ||
print ('-' * window_length) | ||
else: | ||
val_str= str(sd['value']) | ||
str_len= len(val_str) | ||
num_dashes = 80-str_len-2 | ||
num_dashes = window_length-str_len-2 | ||
left_dashes = '-'*int(num_dashes/2) | ||
right_dashes = '-'*int(num_dashes/2+num_dashes%2) | ||
print( left_dashes + ' '+val_str+' '+right_dashes) | ||
else: | ||
val_str= str(sd['value']) | ||
if len(val_str)>29: | ||
print ('{:<50}'.format(sd['name'])) | ||
print ('{:>80}'.format(val_str)) | ||
if len(val_str)>val_length-1: | ||
print (('{:<%d}'%name_length).format(sd['name'])) | ||
print (('{:>%d}'%window_length).format(val_str)) | ||
else: | ||
print ('{:<50}{:>30}'.format(sd['name'],str(sd['value']))) | ||
print ('=' * 80) | ||
print (('{:<%d}{:>%d}'%(name_length,val_length)).format(sd['name'],str(sd['value']))) | ||
print ('=' * window_length) | ||
print('') | ||
|