Entering edit mode
2.9 years ago
anasjamshed
▴
140
I am trying this code to read multiple vcf files present in 2 different folders:
import os
import pandas as pd
import vcf
# Folder Path
path1 = "C://Users//USER//Desktop//Anas/VCFs_1/"
path2 = "C://Users//USER//Desktop//Anas/VCFs_2/"
#os.chdir(path1)
def read(f1,f2):
reader = vcf.Reader(open(f1,f2))
df = pd.DataFrame([vars(r) for r in reader])
out = df.merge(pd.DataFrame(df.INFO.tolist()),
left_index=True, right_index=True)
return out
# Read text File
def read_text_file(file_path1,file_path2):
with open(file_path1, 'r') as f:
with open(file_path2,'r') as f:
print(read(path1,path2))
# iterate through all file
for file in os.listdir():
# Check whether the file is in text format or not
if file.endswith(".vcf"):
file_path1 = f"{path1}\{file}"
file_path2 = f"{path2}\{file}"
print(file_path1,"\n\n",file_path2)
But it's giving me a permission error? I have also tried to execute code with admin privileges but nothing happened. There is something wrong with the code.
Can anyone fix it?
It's not actual code.I am trying to modify other code so It could be able to read multiple vcf files present in 2 different folders. Please help to correct it
can anyone help me to correct this code?
I am trying this now:
but still i am getting permission error?