Skip to content

Commit c368aa0

Browse files
author
Tobias Andermann
committed
small bugfixes
1 parent 38d5edb commit c368aa0

File tree

3 files changed

+20
-14
lines changed

3 files changed

+20
-14
lines changed

README.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,18 @@ conda create -n secapr_env secapr
6060
```
6161

6262
### RECENT INSTALLATION ISSUES
63-
In case the above command results in an endless wait while conda is trying to solve the environment, something is not working the way it should with the conda environment creation (we are currenlty investigating what causes this issue for some users). Instead you can manually create the conda environment by running the commands from [this bash script](https://github.com/AntonelliLab/seqcap_processor/blob/master/recipe/install_secapr_env_manually.sh). You can either copy the command one by one into your command line terminal, or download the sh-script and execute it in the command line with `sh install_secapr_env_manually.sh`.
63+
In case the above command results in an endless wait while conda is trying to solve the environment, something is not working the way it should with the conda environment creation (we are currenlty investigating what causes this issue for some users).
6464

65+
Instead you can install the SECAPR environment directly from the GitHub repo. For this first download the file containing the installation instructions with `wget` and execute it with `sh`.
66+
67+
If you don't have `wget` installed on your computer you can install it with `conda install wget`.
68+
69+
```bash
70+
wget https://raw.githubusercontent.com/AntonelliLab/seqcap_processor/master/recipe/install_secapr_env.sh
71+
sh install_secapr_env.sh
72+
```
73+
74+
If you can't run `wget` on your machine, you can instead access the file manually [here](https://raw.githubusercontent.com/AntonelliLab/seqcap_processor/master/recipe/install_secapr_env.sh) and simply copy it's content into your command line terminal.
6575

6676
More information about installing SECAPR, including installation of previous versions and using docker containers, can be found by clicking on the badge below:
6777

secapr/locus_selection.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import subprocess
99
import csv
1010
import pandas as pd
11-
import pickle
11+
import numpy as np
1212
from Bio import SeqIO
1313
from secapr.utils import CompletePath
1414
from secapr.helpers import CreateDir
@@ -298,7 +298,7 @@ def main(args):
298298
if args.reference:
299299
reference_file_dict.setdefault(sample,args.reference)
300300
else:
301-
reference_pickle = os.path.join(path2,'%s_reference.pickle' %sample)
301+
reference_pickle = os.path.join(path2,'%s_reference.txt' %sample)
302302
reference_file_dict.setdefault(sample,reference_pickle)
303303
bam = sample_bam_dict[key][0]
304304
sample_dir, read_depth_file = get_bam_read_cov(bam,output_folder)
@@ -313,14 +313,12 @@ def main(args):
313313
if args.reference:
314314
reference = args.reference
315315
else:
316-
with open(reference_pickle, 'rb') as handle:
317-
reference = pickle.load(handle)
316+
reference = str(np.loadtxt(reference_pickle, dtype=str))
318317
# store reference as pickle in new subfolder
319318
tmp_folder = os.path.join(subfolder,'tmp')
320319
os.makedirs(tmp_folder)
321-
reference_pickle_out = os.path.join(tmp_folder,'%s_reference.pickle'%sample)
322-
with open(reference_pickle_out, 'wb') as handle:
323-
pickle.dump(reference, handle, protocol=pickle.HIGHEST_PROTOCOL)
320+
reference_pickle_out = os.path.join(tmp_folder,'%s_reference.txt'%sample)
321+
np.savetxt(reference_pickle_out, np.array([reference]), fmt='%s')
324322
read_depth_file = subfolder_file_dict[subfolder]
325323
locus_dict_all_samples = summarize_read_depth_files(subfolder,read_depth_file,locus_list,locus_dict_all_samples,sample_id_list,reference)
326324
output_dict = {}

secapr/phase_alleles.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
import configparser
1515
import subprocess
1616
import subprocess
17-
import pickle
17+
import numpy as np
1818
from Bio import SeqIO
1919
from secapr.utils import CompletePath
2020
from secapr.reference_assembly import bam_consensus, join_fastas
@@ -45,7 +45,6 @@ def add_arguments(parser):
4545
)
4646
parser.add_argument(
4747
'--reference',
48-
required=True,
4948
action=CompletePath,
5049
default=None,
5150
help='Provide the reference that was used for read-mapping. If you used the alignment-consensus method, provide the joined_fasta_library.fasta which is found in the reference_seqs folder within the reference-assembly output.'
@@ -165,15 +164,14 @@ def main(args):
165164
if os.path.isdir(path):
166165
subfolder_path = os.path.join(input_folder,subfolder)
167166
if subfolder_path.endswith('_remapped') or subfolder_path.endswith('_locus_selection'):
168-
sample = '_'.join(subfolder.split('_')[:-1])
167+
sample = '_'.join(subfolder.split('_')[:-1]).replace('_locus','')
169168
sample_output_folder = os.path.join(out_dir,'%s_phased' %sample)
170169
if not os.path.exists(sample_output_folder):
171170
os.makedirs(sample_output_folder)
172171
sample_out_list.append(sample_output_folder)
173172
tmp_folder = os.path.join(subfolder_path,'tmp')
174-
reference_pickle = os.path.join(tmp_folder,'%s_reference.pickle' %sample)
175-
#with open(reference_pickle, 'rb') as handle:
176-
# reference = pickle.load(handle)
173+
reference_pickle = os.path.join(tmp_folder,'%s_reference.txt' %sample)
174+
reference = str(np.loadtxt(reference_pickle, dtype=str))
177175
for file in os.listdir(subfolder_path):
178176
if file.endswith("sorted.bam"):
179177
sorted_bam = file

0 commit comments

Comments
 (0)