Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 32 additions & 3 deletions assnake/api/fs_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,32 @@ def get_samples_from_dir(directory_with_reads, modify_name = None):
for s in samples
]

if len(samples_list) == 0:
ending_variant = {'name': 'single_end', 'strands': {'R1': '', 'R2':'_R2'}}
variant_w_ext = ending_variant['strands']['R1'] + ext
globbing_path = os.path.join(directory_with_reads, '*' + variant_w_ext)
files_mathching_pattern = glob.glob(globbing_path)

# get sample names
samples = [
filename.split('/')[-1].replace(variant_w_ext, '') # Take last part of path (basename) and replace _R1/fastq.gz with nothing to get sample name
for filename in files_mathching_pattern
]

# prepare sample dicts
samples_list += [
{
'name_in_run': s,
'modified_name': modify_name(s) if modify_name is not None else s,

'ending_variant_id': ending_variant['name'],
'ending_variant_R1': ending_variant['strands']['R1'],
'ending_variant_R2': ending_variant['strands']['R2'],
'directory': directory_with_reads,
'extension': ext
}
for s in samples
]

return pd.DataFrame(samples_list)

Expand Down Expand Up @@ -105,17 +131,20 @@ def create_links(import_dir, samples, hard = False, create_dir_if_not_exist = Fa

if rename:
os.rename(src_r1, dst_r1)
os.rename(src_r2, dst_r2)
if os.path.exists(src_r2):
os.rename(src_r2, dst_r2)
return

if hard:
copy2(src_r1, dst_r1)
copy2(src_r2, dst_r2)
if os.path.exists(src_r2):
copy2(src_r2, dst_r2)
return

try:
os.symlink(src_r1, dst_r1)
os.symlink(src_r2, dst_r2)
if os.path.exists(src_r2):
os.symlink(src_r2, dst_r2)
except FileExistsError as e:
print(e)

11 changes: 10 additions & 1 deletion assnake/api/loaders.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,16 @@ def load_sample(fs_prefix, df, preproc, df_sample,
if report_size:
size = os.path.getsize(r1) + os.path.getsize(r2)
sample_dict.update({'size': bytes2human(size, symbols='iec'), 'bytes': size})
elif os.path.isfile(r1):
containers.append(p)
if len(p) > len(final_preproc):
final_preproc = p
if report_size:
size = os.path.getsize(r1)
sample_dict.update({'size': bytes2human(size, symbols='iec'), 'bytes': size})
else:
click.secho('There are no reads in a path: %s'%r1, fg='red')
exit()
return {'df':df,
'df_sample':df_sample,
'df_sample':df_sample,
Expand All @@ -108,7 +118,6 @@ def load_sample_set(wc_config, fs_prefix, df, preproc, samples_to_add = [], do_n
do_not_add: list of sample names NOT to add
pattern: sample names must match this glob pattern to be included.
'''

if wc_config is None:
wc_config = load_wc_config()

Expand Down
2 changes: 1 addition & 1 deletion assnake/cli/assnake_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def dataset():
dataset.add_command(dataset_commands.df_import_reads)
dataset.add_command(dataset_commands.df_delete)
dataset.add_command(dataset_commands.rescan_dataset)

dataset.add_command(dataset_commands.df_update_info_wrapper)

#---------------------------------------------------------------------------------------
# assnake RESULT *** group
Expand Down
Loading