Combining 2 Text File And Make A New One In Python
I have 2 big text files like the following small examples. there are 2 files (major and minor). in both major and minor files there are 4 columns. in the major file the difference
Solution 1:
You should do something like this
final = []
for i, j in zip(minor_list, major_list):
final.append(i, j)
Solution 2:
Maybe its a typo in your code I can see that your missing a tab at your if minor_list[i]
final = []
for i in minor_list:
for j in major_list
if minor_list[i] == major_list[j] and minor_list[i+1] <= major_list[j+1] and minor_list[i+2] >= major_list[j+2]:
final.append(i)
should be
final = []
for i in minor_list:
for j in major_list
if minor_list[i] == major_list[j] and minor_list[i+1] <= major_list[j+1] and minor_list[i+2] >= major_list[j+2]:
final.append(i)
Solution 3:
Do you HAVE to use Python for this? If you install "bedtools" in bash shell, this can be accomplished with the following line:
bedtools intersect -wa -wb -a minor.bed -b major.bed > intersected_file.bed
A few bioinformatics tools are linux/mac-only, so if you're going to be doing any amount of bioinformatics, it's worth learning how to script in shell.
Post a Comment for "Combining 2 Text File And Make A New One In Python"