-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13 from bcgsc/ntjoin_multi_ref_fix
Prepare for v1.0.0 release
- Loading branch information
Showing
7 changed files
with
229 additions
and
153 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
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,29 @@ | ||
#!/usr/bin/env python3 | ||
|
||
# Split a fasta file into multiple files, one per sequence and create a reference config file for ntJoin | ||
# Usage: split_fasta.py <fasta file> <output directory> <config file> | ||
|
||
import sys | ||
|
||
ntjoin_reference_weight = 2 #Refer to ntJoin README for more info: https://github.com/bcgsc/ntJoin | ||
input = sys.argv[1] | ||
output = sys.argv[2] | ||
config = sys.argv[3] | ||
ref_list = [] | ||
with open(input, 'r') as f: | ||
for line in f: | ||
line = line.strip() | ||
if line.startswith('>'): | ||
header = line | ||
filename = header.split(' ')[0].strip('>') + '.fasta' | ||
else: | ||
sequence = line | ||
with open(output + '/' + filename, 'w') as g: | ||
g.write(header + '\n') | ||
g.write(sequence + '\n') | ||
ref_list.append(f'{output}/{filename},{ntjoin_reference_weight}') | ||
|
||
with open(config, 'w') as f: | ||
f.write('\n'.join(ref_list)) | ||
|
||
|
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
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
Oops, something went wrong.