I am writing a program to compare two different files.
For each line in file1 i want to compare it to all the lines in file2, then go to the next line in file1.
the code i have below is not looping back to the next line in file1, can anyone give me any suggestions to help?
For each line in file1 i want to compare it to all the lines in file2, then go to the next line in file1.
the code i have below is not looping back to the next line in file1, can anyone give me any suggestions to help?
Code:
#! /usr/bin/env python import sys import fileinput # Open the two files f1 = open(sys.argv[1], "r") f2 = open(sys.argv[2], "r") for line in f1: chrR,chrStart,chrEnd,name,score,strand1,codingStart,codingEnd,itemRbg,blockCount,blockSize,BlockStart = line.strip().split() chr = range(int(chrStart), int(chrEnd)) lncRNA = set(chr) for line in f2: chrC,clustStart,clustEnd,annote,score,strand = line.strip().split() clust = range(int(clustStart), int(clustEnd)) cluster = set(clust) if strand1 == '-': if chrR == chrC: if strand1 == strand: if lncRNA & cluster: print name, annote, 'transcript' else: continue continue break
Comment