Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Public init v2 #712

Closed
wants to merge 2 commits into from
Closed
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
4 changes: 2 additions & 2 deletions atlas/atlas.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

from snakemake.io import load_configfile
from .make_config import validate_config
from .init.atlas_init import run_init # , run_init_sra
from .init.atlas_init import run_init, run_init_sra

from .__init__ import __version__

Expand Down Expand Up @@ -66,7 +66,7 @@ def cli(obj):
cli.add_command(run_init)


# cli.add_command(run_init_sra)
cli.add_command(run_init_sra)


def get_snakefile(file="workflow/Snakefile"):
Expand Down
50 changes: 18 additions & 32 deletions atlas/init/atlas_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,13 @@ def run_init(
"ERR1190946 PRJEB20796\n\n"
"Reads are automatically downloaded and only temporarily stored on your machine.",
)
@click.argument("identifiers", nargs=-1, type=str)
@click.option(
"-r",
"--run-table",
type=click.Path(dir_okay=True, writable=True, resolve_path=True),
show_default=True,
help="location to the run table",
)
@click.option(
"-d",
"--db-dir",
Expand Down Expand Up @@ -228,20 +234,13 @@ def run_init(
help="Ignore the paired end reads from your SRA samples",
)
def run_init_sra(
identifiers,
run_table,
db_dir,
working_dir,
skip_qc=False,
ignore_paired=False,
overwrite=False,
):
""""""

if len(identifiers) == 0:
click.echo(
"No SRA identifiers supplied, exiting. Use --help for more information."
)
sys.exit(1)

from .get_SRA_runinfo import get_runtable_from_ids
from .parse_sra import (
Expand All @@ -261,32 +260,19 @@ def run_init_sra(

runinfo_file = working_dir / "RunInfo.tsv"

if os.path.exists(runinfo_file) & (not overwrite):
if not ((len(identifiers) == 1) & (identifiers[0].lower() == "continue")):
logger.error(
f"Found Filtered runinfo file {runinfo_file}"
"If you want me to continue with this one use 'continue' instead of identifiers. "
"Alternatively use --overwrite to overwrite the files"
)
sys.exit(1)

else:
logger.info(f"Downloading runinfo from SRA")

# Create runinfo table in folder for SRA reads
runinfo_file_original = SRA_subfolder / "RunInfo_original.tsv"

get_runtable_from_ids(identifiers, runinfo_file_original)
# Create runinfo table in folder for SRA reads
# runinfo_file_original = SRA_subfolder / "RunInfo_original.tsv"
runinfo_file_original = run_table

# Parse runtable
RunTable = load_and_validate_runinfo_table(runinfo_file_original)
# Parse runtable
RunTable = load_and_validate_runinfo_table(runinfo_file_original)

# Filter runtable
RunTable_filtered = filter_runinfo(RunTable, ignore_paired=ignore_paired)
# Filter runtable
RunTable_filtered = filter_runinfo(RunTable, ignore_paired=ignore_paired)

# save filtered runtable
logger.info(f"Write filtered runinfo to {runinfo_file}")
RunTable_filtered.to_csv(runinfo_file, sep="\t")
# save filtered runtable
logger.info(f"Write filtered runinfo to {runinfo_file}")
RunTable_filtered.to_csv(runinfo_file, sep=",")

# validate if can be merged
RunTable = validate_merging_runinfo(runinfo_file)
Expand Down
6 changes: 3 additions & 3 deletions atlas/init/parse_sra.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@


def load_and_validate_runinfo_table(path):
RunTable = pd.read_csv(path, sep="\t", index_col=0)
RunTable = pd.read_csv(path, sep=",", index_col=0)

# validate sra table
format_error = False
Expand All @@ -24,7 +24,7 @@ def load_and_validate_runinfo_table(path):
"LibraryLayout",
"LibrarySource",
"LibrarySelection",
"LibraryStrategy",
#"LibraryStrategy",
"BioSample",
]
for header in Expected_headers:
Expand Down Expand Up @@ -72,7 +72,7 @@ def filter_runinfo(RunTable, ignore_paired=False):
f"Filtered out {Difference} runs"
)

for key in ["LibrarySelection", "LibraryStrategy"]:
for key in ["LibrarySelection"]: #, "LibraryStrategy"]:
Nruns_before = RunTable.shape[0]
All_values = RunTable[key].unique()
if any(RunTable[key] != Expected_library_values[key]):
Expand Down