from pathlib import Path


def check_single_replicate_and_resolve_paths(project_directory):
	"""
	Check read files and resolve paths
	"""
	sample_data = []
	for r1 in project_directory.rglob("*_L001_R1_001.fastq.gz"):
		r1 = r1.resolve()
		r2 = Path(str(r1).replace("_L001_R1_001.fastq.gz", "_L001_R2_001.fastq.gz"))
		if r2.exists():
			r2 = r2.resolve()
		else:
			raise ValueError(f"R2 cannot be found {r2}")
		sample_name = "_".join(r1.name.replace("_L001_R1_001.fastq.gz", '').split("_")[:-1])
		sample_data.append([str(sample_name), str(r1), str(r2)])
	
	print(f"{len(sample_data)} samples detected")
	return sample_data