I have generated two multi-component lists with the following script:
list1 = list()
for line in infile1.readlines():
list1.append(line.split('\t'))
list2 = list()
for line in infile2.readlines():
list2.append(line.split(‘\t’))
The lists look like this:
list1 = ('1960', 'chr17', '+', 'RNF213'), ('1963', 'chr16', '+', 'SF3B3'), ('1964', 'chr4', '-', 'GPRIN3')...
list2 = ('1482', 'miR-K12-1'), ('1018', 'miR-K12-4-5p'), ('1960', 'miR-K12-12')...
The first element from the first entry in list1 (in this case "1960") will match the first element of one or more entries in list2. What I would like to do is locate each match and then add the last element of the list2 entry to the list1 entry. An example of the desired output would be:
('1960', 'chr17', '+', 'RNF213', 'miR-K12-12')
I have tried this, but it returns nothing:
result = []
for list1[0] in list1:
if list1[0] == list2[0]:
result.append((list1[0:], list2[1]))