<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://teaching.healthtech.dtu.dk:443/22101/index.php?action=history&amp;feed=atom&amp;title=Lists%2FSequences</id>
	<title>Lists/Sequences - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://teaching.healthtech.dtu.dk:443/22101/index.php?action=history&amp;feed=atom&amp;title=Lists%2FSequences"/>
	<link rel="alternate" type="text/html" href="https://teaching.healthtech.dtu.dk:443/22101/index.php?title=Lists/Sequences&amp;action=history"/>
	<updated>2026-05-17T16:24:09Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.41.0</generator>
	<entry>
		<id>https://teaching.healthtech.dtu.dk:443/22101/index.php?title=Lists/Sequences&amp;diff=82&amp;oldid=prev</id>
		<title>WikiSysop: /* Exercises to be handed in */</title>
		<link rel="alternate" type="text/html" href="https://teaching.healthtech.dtu.dk:443/22101/index.php?title=Lists/Sequences&amp;diff=82&amp;oldid=prev"/>
		<updated>2024-11-06T05:40:07Z</updated>

		<summary type="html">&lt;p&gt;&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;Exercises to be handed in&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 07:40, 6 November 2024&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l21&quot;&gt;Line 21:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 21:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# Searching for accession numbers. In the file &amp;#039;&amp;#039;ex5.acc&amp;#039;&amp;#039; there are 6461 unique GenBank accession numbers (taken from HU6800 DNA array chip). An inexperienced bioinformatician unfortunately fouled up the list, so many of the accession numbers appears more than once. Make a program that first reads the file into a list, then ask for an accession number and counts how many times it appears in the list and displays the result.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# Searching for accession numbers. In the file &amp;#039;&amp;#039;ex5.acc&amp;#039;&amp;#039; there are 6461 unique GenBank accession numbers (taken from HU6800 DNA array chip). An inexperienced bioinformatician unfortunately fouled up the list, so many of the accession numbers appears more than once. Make a program that first reads the file into a list, then ask for an accession number and counts how many times it appears in the list and displays the result.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# Different search for accession numbers. This program is similar to the above. First read the file into a list, then continue to ask for accession numbers and check if they are in the list (yes/no, not a count). Keep searching for accession numbers until STOP is entered. Hint: this is 2 loops inside one another.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# Different search for accession numbers. This program is similar to the above. First read the file into a list, then continue to ask for accession numbers and check if they are in the list (yes/no, not a count). Keep searching for accession numbers until STOP is entered. Hint: this is 2 loops inside one another.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# &amp;lt;font color=&quot;#AA00FF&quot;&amp;gt;You need to clean up the &#039;&#039;ex5.acc&#039;&#039; file. The first step is to sort the accession numbers alphabetically. You must program a sorting algorithm. There are many different algorithms for sorting, but let&#039;s pick a simple one - Bubble Sort.&amp;lt;br&amp;gt;It goes like this. Read the accessions into a list like the previous exercises. Go through the list looking at pairs of accessions (at position i &amp;amp; i+1). If a pair is in the wrong order, you switch them. Repeat going through the list until you have gone through the entire list without switching once. Now the list is sorted and you save the list in the &#039;&#039;sorted5.acc&#039;&#039; file.&amp;lt;br&amp;gt;Note: &#039;&#039;&#039;It takes 10-30 sec to run this program&#039;&#039;&#039;. There is room for optimization in the described algorithm and it is in any case not the most efficient method. You are free to implement a different method. &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;String &lt;/del&gt;can be compared directly with each other using the operators &amp;lt;nowiki&amp;gt;==, !=, &amp;gt;, &amp;lt;, &amp;gt;=, &amp;lt;=.&amp;lt;/nowiki&amp;gt;&amp;lt;/font&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# &amp;lt;font color=&quot;#AA00FF&quot;&amp;gt;You need to clean up the &#039;&#039;ex5.acc&#039;&#039; file. The first step is to sort the accession numbers alphabetically. You must program a sorting algorithm. There are many different algorithms for sorting, but let&#039;s pick a simple one - Bubble Sort.&amp;lt;br&amp;gt;It goes like this. Read the accessions into a list like the previous exercises. Go through the list looking at pairs of accessions (at position i &amp;amp; i+1). If a pair is in the wrong order, you switch them. Repeat going through the list until you have gone through the entire list without switching once. Now the list is sorted and you save the list in the &#039;&#039;sorted5.acc&#039;&#039; file.&amp;lt;br&amp;gt;Note: &#039;&#039;&#039;It takes 10-30 sec to run this program&#039;&#039;&#039;. There is room for optimization in the described algorithm and it is in any case not the most efficient method. You are free to implement a different method. &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;Strings &lt;/ins&gt;can be compared directly with each other using the operators &amp;lt;nowiki&amp;gt;==, !=, &amp;gt;, &amp;lt;, &amp;gt;=, &amp;lt;=.&amp;lt;/nowiki&amp;gt;&amp;lt;/font&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# It is now time to find the unique accession numbers, so you only have one of each - no duplicates. Read the accessions from &amp;#039;&amp;#039;sorted5.acc&amp;#039;&amp;#039; into a list. Since the list is now sorted, the duplicates are &amp;quot;next&amp;quot; to each other, which makes them easy to find. Make a &amp;#039;&amp;#039;&amp;#039;new&amp;#039;&amp;#039;&amp;#039; list with the unique accessions from the old list, and save that list in the file &amp;#039;&amp;#039;clean5.acc&amp;#039;&amp;#039;. Check that you have 6461 accessions, one per line.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# It is now time to find the unique accession numbers, so you only have one of each - no duplicates. Read the accessions from &amp;#039;&amp;#039;sorted5.acc&amp;#039;&amp;#039; into a list. Since the list is now sorted, the duplicates are &amp;quot;next&amp;quot; to each other, which makes them easy to find. Make a &amp;#039;&amp;#039;&amp;#039;new&amp;#039;&amp;#039;&amp;#039; list with the unique accessions from the old list, and save that list in the file &amp;#039;&amp;#039;clean5.acc&amp;#039;&amp;#039;. Check that you have 6461 accessions, one per line.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# In this exercise you have to do the same and achieve the same result in a different way as the previous exercise. Instead of making a new list with the unique accessions, just keep the old list and remove the duplicates. You can use &amp;#039;&amp;#039;&amp;#039;del&amp;#039;&amp;#039;&amp;#039; or &amp;#039;&amp;#039;&amp;#039;pop&amp;#039;&amp;#039;&amp;#039; to remove elements. If you run into trouble imagine your code executed on this list: [1, 2, 2, 3, 3, 3, 4, 4, 4, 4]&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# In this exercise you have to do the same and achieve the same result in a different way as the previous exercise. Instead of making a new list with the unique accessions, just keep the old list and remove the duplicates. You can use &amp;#039;&amp;#039;&amp;#039;del&amp;#039;&amp;#039;&amp;#039; or &amp;#039;&amp;#039;&amp;#039;pop&amp;#039;&amp;#039;&amp;#039; to remove elements. If you run into trouble imagine your code executed on this list: [1, 2, 2, 3, 3, 3, 4, 4, 4, 4]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>WikiSysop</name></author>
	</entry>
	<entry>
		<id>https://teaching.healthtech.dtu.dk:443/22101/index.php?title=Lists/Sequences&amp;diff=81&amp;oldid=prev</id>
		<title>WikiSysop: /* Exercises to be handed in */</title>
		<link rel="alternate" type="text/html" href="https://teaching.healthtech.dtu.dk:443/22101/index.php?title=Lists/Sequences&amp;diff=81&amp;oldid=prev"/>
		<updated>2024-11-06T05:39:52Z</updated>

		<summary type="html">&lt;p&gt;&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;Exercises to be handed in&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 07:39, 6 November 2024&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l21&quot;&gt;Line 21:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 21:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# Searching for accession numbers. In the file &amp;#039;&amp;#039;ex5.acc&amp;#039;&amp;#039; there are 6461 unique GenBank accession numbers (taken from HU6800 DNA array chip). An inexperienced bioinformatician unfortunately fouled up the list, so many of the accession numbers appears more than once. Make a program that first reads the file into a list, then ask for an accession number and counts how many times it appears in the list and displays the result.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# Searching for accession numbers. In the file &amp;#039;&amp;#039;ex5.acc&amp;#039;&amp;#039; there are 6461 unique GenBank accession numbers (taken from HU6800 DNA array chip). An inexperienced bioinformatician unfortunately fouled up the list, so many of the accession numbers appears more than once. Make a program that first reads the file into a list, then ask for an accession number and counts how many times it appears in the list and displays the result.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# Different search for accession numbers. This program is similar to the above. First read the file into a list, then continue to ask for accession numbers and check if they are in the list (yes/no, not a count). Keep searching for accession numbers until STOP is entered. Hint: this is 2 loops inside one another.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# Different search for accession numbers. This program is similar to the above. First read the file into a list, then continue to ask for accession numbers and check if they are in the list (yes/no, not a count). Keep searching for accession numbers until STOP is entered. Hint: this is 2 loops inside one another.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# &amp;lt;font color=&quot;#AA00FF&quot;&amp;gt;You need to clean up the &#039;&#039;ex5.acc&#039;&#039; file. The first step is to sort the accession numbers alphabetically. You must program a sorting algorithm. There are many different algorithms for sorting, but let&#039;s pick a simple one - Bubble Sort.&amp;lt;br&amp;gt;It goes like this. Read the accessions into a list like the previous exercises. Go through the list looking at pairs of accessions (at position i &amp;amp; i+1). If a pair is in the wrong order, you switch them. Repeat going through the list until you have gone through the entire list without switching once. Now the list is sorted and you save the list in the &#039;&#039;sorted5.acc&#039;&#039; file.&amp;lt;br&amp;gt;Note: &#039;&#039;&#039;It takes 10-30 sec to run this program&#039;&#039;&#039;. There is room for optimization in the described algorithm and it is in any case not the most efficient method. You are free to implement a different method.&amp;lt;/font&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# &amp;lt;font color=&quot;#AA00FF&quot;&amp;gt;You need to clean up the &#039;&#039;ex5.acc&#039;&#039; file. The first step is to sort the accession numbers alphabetically. You must program a sorting algorithm. There are many different algorithms for sorting, but let&#039;s pick a simple one - Bubble Sort.&amp;lt;br&amp;gt;It goes like this. Read the accessions into a list like the previous exercises. Go through the list looking at pairs of accessions (at position i &amp;amp; i+1). If a pair is in the wrong order, you switch them. Repeat going through the list until you have gone through the entire list without switching once. Now the list is sorted and you save the list in the &#039;&#039;sorted5.acc&#039;&#039; file.&amp;lt;br&amp;gt;Note: &#039;&#039;&#039;It takes 10-30 sec to run this program&#039;&#039;&#039;. There is room for optimization in the described algorithm and it is in any case not the most efficient method. You are free to implement a different method. &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;String can be compared directly with each other using the operators &amp;lt;nowiki&amp;gt;==, !=, &amp;gt;, &amp;lt;, &amp;gt;=, &amp;lt;=.&amp;lt;/nowiki&amp;gt;&lt;/ins&gt;&amp;lt;/font&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# It is now time to find the unique accession numbers, so you only have one of each - no duplicates. Read the accessions from &amp;#039;&amp;#039;sorted5.acc&amp;#039;&amp;#039; into a list. Since the list is now sorted, the duplicates are &amp;quot;next&amp;quot; to each other, which makes them easy to find. Make a &amp;#039;&amp;#039;&amp;#039;new&amp;#039;&amp;#039;&amp;#039; list with the unique accessions from the old list, and save that list in the file &amp;#039;&amp;#039;clean5.acc&amp;#039;&amp;#039;. Check that you have 6461 accessions, one per line.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# It is now time to find the unique accession numbers, so you only have one of each - no duplicates. Read the accessions from &amp;#039;&amp;#039;sorted5.acc&amp;#039;&amp;#039; into a list. Since the list is now sorted, the duplicates are &amp;quot;next&amp;quot; to each other, which makes them easy to find. Make a &amp;#039;&amp;#039;&amp;#039;new&amp;#039;&amp;#039;&amp;#039; list with the unique accessions from the old list, and save that list in the file &amp;#039;&amp;#039;clean5.acc&amp;#039;&amp;#039;. Check that you have 6461 accessions, one per line.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# In this exercise you have to do the same and achieve the same result in a different way as the previous exercise. Instead of making a new list with the unique accessions, just keep the old list and remove the duplicates. You can use &amp;#039;&amp;#039;&amp;#039;del&amp;#039;&amp;#039;&amp;#039; or &amp;#039;&amp;#039;&amp;#039;pop&amp;#039;&amp;#039;&amp;#039; to remove elements. If you run into trouble imagine your code executed on this list: [1, 2, 2, 3, 3, 3, 4, 4, 4, 4]&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# In this exercise you have to do the same and achieve the same result in a different way as the previous exercise. Instead of making a new list with the unique accessions, just keep the old list and remove the duplicates. You can use &amp;#039;&amp;#039;&amp;#039;del&amp;#039;&amp;#039;&amp;#039; or &amp;#039;&amp;#039;&amp;#039;pop&amp;#039;&amp;#039;&amp;#039; to remove elements. If you run into trouble imagine your code executed on this list: [1, 2, 2, 3, 3, 3, 4, 4, 4, 4]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>WikiSysop</name></author>
	</entry>
	<entry>
		<id>https://teaching.healthtech.dtu.dk:443/22101/index.php?title=Lists/Sequences&amp;diff=72&amp;oldid=prev</id>
		<title>WikiSysop: /* Exercises for extra practice */</title>
		<link rel="alternate" type="text/html" href="https://teaching.healthtech.dtu.dk:443/22101/index.php?title=Lists/Sequences&amp;diff=72&amp;oldid=prev"/>
		<updated>2024-10-30T08:51:44Z</updated>

		<summary type="html">&lt;p&gt;&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;Exercises for extra practice&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 10:51, 30 October 2024&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l31&quot;&gt;Line 31:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 31:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* Read a file with numbers into two lists. The first number in the file goes to the first list, the second number to the second list, the third number to the first list, and so forth - alternating numbers to alternating lists. Compute the sum of the two lists and display. Files &amp;#039;&amp;#039;ex1_1.dat&amp;#039;&amp;#039;, &amp;#039;&amp;#039;ex1_2.dat&amp;#039;&amp;#039; &amp;amp; &amp;#039;&amp;#039;ex1_3.dat&amp;#039;&amp;#039; are good to use for this.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* Read a file with numbers into two lists. The first number in the file goes to the first list, the second number to the second list, the third number to the first list, and so forth - alternating numbers to alternating lists. Compute the sum of the two lists and display. Files &amp;#039;&amp;#039;ex1_1.dat&amp;#039;&amp;#039;, &amp;#039;&amp;#039;ex1_2.dat&amp;#039;&amp;#039; &amp;amp; &amp;#039;&amp;#039;ex1_3.dat&amp;#039;&amp;#039; are good to use for this.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* Now compute the same sums - without the lists :-)&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* Now compute the same sums - without the lists :-)&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* Ask for files names and read the numbers in the file into a list. Continue to ask for file names and add the numbers to the list until you enter STOP. Now compute the sum of the numbers in the list and display the result. Files &#039;&#039;ex1_1.dat&#039;&#039;, &#039;&#039;ex1_2.dat&#039;&#039; &amp;amp; &#039;&#039;ex1_3.dat&#039;&#039; are good to use for this.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* Ask for files names and read the numbers in the file into a list. Continue to ask for file names and add the numbers to the list until you enter STOP&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;. Your list of numbers will simply grow with each file you add&lt;/ins&gt;. Now compute the sum of the numbers in the list and display the result. Files &#039;&#039;ex1_1.dat&#039;&#039;, &#039;&#039;ex1_2.dat&#039;&#039; &amp;amp; &#039;&#039;ex1_3.dat&#039;&#039; are good to use for this.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>WikiSysop</name></author>
	</entry>
	<entry>
		<id>https://teaching.healthtech.dtu.dk:443/22101/index.php?title=Lists/Sequences&amp;diff=71&amp;oldid=prev</id>
		<title>WikiSysop: /* Exercises for extra practice */</title>
		<link rel="alternate" type="text/html" href="https://teaching.healthtech.dtu.dk:443/22101/index.php?title=Lists/Sequences&amp;diff=71&amp;oldid=prev"/>
		<updated>2024-10-30T08:50:46Z</updated>

		<summary type="html">&lt;p&gt;&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;Exercises for extra practice&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 10:50, 30 October 2024&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l27&quot;&gt;Line 27:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 27:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;== Exercises for extra practice ==&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;== Exercises for extra practice ==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* Read two files with numbers into two lists. Files &amp;#039;&amp;#039;ex1_1.dat&amp;#039;&amp;#039;, &amp;#039;&amp;#039;ex1_2.dat&amp;#039;&amp;#039; &amp;amp; &amp;#039;&amp;#039;ex1_3.dat&amp;#039;&amp;#039; are good to use for this. Now add the numbers together, like the first number in the first file with the first number in the second file, and so forth, i.e. add the column in the file row-wise. You could also consider the numbers in a file to be a vector, and then you add two vectors together. Save the output (a list of numbers, one number per line) in a new file - you decide the name.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* Read two files with numbers into two lists. Files &amp;#039;&amp;#039;ex1_1.dat&amp;#039;&amp;#039;, &amp;#039;&amp;#039;ex1_2.dat&amp;#039;&amp;#039; &amp;amp; &amp;#039;&amp;#039;ex1_3.dat&amp;#039;&amp;#039; are good to use for this. Now add the numbers together, like the first number in the first file with the first number in the second file, and so forth, i.e. add the column in the file row-wise. You could also consider the numbers in a file to be a vector, and then you add two vectors together. Save the output (a list of numbers, one number per line) in a new file - you decide the name.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* Continuing previous exercise: Corrupt your input files a bit, change some numbers to not-numbers, like words or empty lines. Make your program work on these files too, assuming anything you can not read is ignored - &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;you can &quot;pretend&quot; that there is a zero on the &lt;/del&gt;line you can not convert to a number.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* Continuing previous exercise: Corrupt your input files a bit, change some numbers to not-numbers, like words or empty lines. Make your program work on these files too, assuming anything you can not read is ignored - &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;consider any &lt;/ins&gt;line you can not convert to a number &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;as containing a zero&lt;/ins&gt;.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* Continuing previous exercise: Make the program work even if the input files do not have the same length, just assume zero for the missing lines in the short file. BTW, you do not know which input is short.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* Continuing previous exercise: Make the program work even if the input files do not have the same length, just assume zero for the missing lines in the short file. BTW, you do not know which input is short.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* Read a file with numbers into two lists. The first number in the file goes to the first list, the second number to the second list, the third number to the first list, and so forth - alternating numbers to alternating lists. Compute the sum of the two lists and display. Files &amp;#039;&amp;#039;ex1_1.dat&amp;#039;&amp;#039;, &amp;#039;&amp;#039;ex1_2.dat&amp;#039;&amp;#039; &amp;amp; &amp;#039;&amp;#039;ex1_3.dat&amp;#039;&amp;#039; are good to use for this.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* Read a file with numbers into two lists. The first number in the file goes to the first list, the second number to the second list, the third number to the first list, and so forth - alternating numbers to alternating lists. Compute the sum of the two lists and display. Files &amp;#039;&amp;#039;ex1_1.dat&amp;#039;&amp;#039;, &amp;#039;&amp;#039;ex1_2.dat&amp;#039;&amp;#039; &amp;amp; &amp;#039;&amp;#039;ex1_3.dat&amp;#039;&amp;#039; are good to use for this.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* Now compute the same sums - without the lists :-)&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* Now compute the same sums - without the lists :-)&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* Ask for files names and read the numbers in the file into a list. Continue to ask for file names and add the numbers to the list until you enter STOP. Now compute the sum of the numbers in the list and display the result. Files &amp;#039;&amp;#039;ex1_1.dat&amp;#039;&amp;#039;, &amp;#039;&amp;#039;ex1_2.dat&amp;#039;&amp;#039; &amp;amp; &amp;#039;&amp;#039;ex1_3.dat&amp;#039;&amp;#039; are good to use for this.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* Ask for files names and read the numbers in the file into a list. Continue to ask for file names and add the numbers to the list until you enter STOP. Now compute the sum of the numbers in the list and display the result. Files &amp;#039;&amp;#039;ex1_1.dat&amp;#039;&amp;#039;, &amp;#039;&amp;#039;ex1_2.dat&amp;#039;&amp;#039; &amp;amp; &amp;#039;&amp;#039;ex1_3.dat&amp;#039;&amp;#039; are good to use for this.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>WikiSysop</name></author>
	</entry>
	<entry>
		<id>https://teaching.healthtech.dtu.dk:443/22101/index.php?title=Lists/Sequences&amp;diff=70&amp;oldid=prev</id>
		<title>WikiSysop: /* Exercises to be handed in */</title>
		<link rel="alternate" type="text/html" href="https://teaching.healthtech.dtu.dk:443/22101/index.php?title=Lists/Sequences&amp;diff=70&amp;oldid=prev"/>
		<updated>2024-10-30T08:48:39Z</updated>

		<summary type="html">&lt;p&gt;&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;Exercises to be handed in&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 10:48, 30 October 2024&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l21&quot;&gt;Line 21:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 21:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# Searching for accession numbers. In the file &amp;#039;&amp;#039;ex5.acc&amp;#039;&amp;#039; there are 6461 unique GenBank accession numbers (taken from HU6800 DNA array chip). An inexperienced bioinformatician unfortunately fouled up the list, so many of the accession numbers appears more than once. Make a program that first reads the file into a list, then ask for an accession number and counts how many times it appears in the list and displays the result.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# Searching for accession numbers. In the file &amp;#039;&amp;#039;ex5.acc&amp;#039;&amp;#039; there are 6461 unique GenBank accession numbers (taken from HU6800 DNA array chip). An inexperienced bioinformatician unfortunately fouled up the list, so many of the accession numbers appears more than once. Make a program that first reads the file into a list, then ask for an accession number and counts how many times it appears in the list and displays the result.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# Different search for accession numbers. This program is similar to the above. First read the file into a list, then continue to ask for accession numbers and check if they are in the list (yes/no, not a count). Keep searching for accession numbers until STOP is entered. Hint: this is 2 loops inside one another.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# Different search for accession numbers. This program is similar to the above. First read the file into a list, then continue to ask for accession numbers and check if they are in the list (yes/no, not a count). Keep searching for accession numbers until STOP is entered. Hint: this is 2 loops inside one another.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# &amp;lt;font color=&quot;#AA00FF&quot;&amp;gt;You need to clean up the &#039;&#039;ex5.acc&#039;&#039; file. The first step is to sort the accession numbers alphabetically. You must program a sorting algorithm. There are many different algorithms for sorting, but let&#039;s pick a simple one - Bubble Sort.&amp;lt;br&amp;gt;It goes like this. Read the accessions into a list like the previous exercises. Go through the list looking at pairs of accessions (at position i &amp;amp; i+1). If a pair is in the wrong order, you switch them. Repeat going through the list until you have gone through the entire list without switching once. Now the list is sorted and you save the list in the &#039;&#039;sorted5.acc&#039;&#039; file.&amp;lt;br&amp;gt;Note: There is room for optimization in the described algorithm and it is in any case not the most efficient method. You are free to implement a different method.&amp;lt;/font&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# &amp;lt;font color=&quot;#AA00FF&quot;&amp;gt;You need to clean up the &#039;&#039;ex5.acc&#039;&#039; file. The first step is to sort the accession numbers alphabetically. You must program a sorting algorithm. There are many different algorithms for sorting, but let&#039;s pick a simple one - Bubble Sort.&amp;lt;br&amp;gt;It goes like this. Read the accessions into a list like the previous exercises. Go through the list looking at pairs of accessions (at position i &amp;amp; i+1). If a pair is in the wrong order, you switch them. Repeat going through the list until you have gone through the entire list without switching once. Now the list is sorted and you save the list in the &#039;&#039;sorted5.acc&#039;&#039; file.&amp;lt;br&amp;gt;Note: &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&#039;&#039;&#039;It takes 10-30 sec to run this program&#039;&#039;&#039;. &lt;/ins&gt;There is room for optimization in the described algorithm and it is in any case not the most efficient method. You are free to implement a different method.&amp;lt;/font&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# It is now time to find the unique accession numbers, so you only have one of each - no duplicates. Read the accessions from &#039;&#039;sorted5.acc&#039;&#039; into a list. Since the list is now sorted, the duplicates are &quot;next&quot; to each other, which makes them easy to find. Make a new list with the unique accessions from the old list, and save that list in the file &#039;&#039;clean5.acc&#039;&#039;. Check that you have 6461 accessions, one per line.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# It is now time to find the unique accession numbers, so you only have one of each - no duplicates. Read the accessions from &#039;&#039;sorted5.acc&#039;&#039; into a list. Since the list is now sorted, the duplicates are &quot;next&quot; to each other, which makes them easy to find. Make a &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&#039;&#039;&#039;&lt;/ins&gt;new&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&#039;&#039;&#039; &lt;/ins&gt;list with the unique accessions from the old list, and save that list in the file &#039;&#039;clean5.acc&#039;&#039;. Check that you have 6461 accessions, one per line.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# In this exercise you have to do the same and achieve the same result in a different way as the previous exercise. Instead of making a new list with the unique accessions, just keep the old list and remove the duplicates &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;using &lt;/del&gt;&#039;&#039;&#039;del&#039;&#039;&#039; or &#039;&#039;&#039;pop&#039;&#039;&#039;. If you run into trouble imagine your code executed on this list: [1, 2, 2, 3, 3, 3, 4, 4, 4, 4]&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# In this exercise you have to do the same and achieve the same result in a different way as the previous exercise. Instead of making a new list with the unique accessions, just keep the old list and remove the duplicates&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;. You can use &lt;/ins&gt;&#039;&#039;&#039;del&#039;&#039;&#039; or &#039;&#039;&#039;pop&#039;&#039;&#039; &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;to remove elements&lt;/ins&gt;. If you run into trouble imagine your code executed on this list: [1, 2, 2, 3, 3, 3, 4, 4, 4, 4]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;== Exercises for extra practice ==&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;== Exercises for extra practice ==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>WikiSysop</name></author>
	</entry>
	<entry>
		<id>https://teaching.healthtech.dtu.dk:443/22101/index.php?title=Lists/Sequences&amp;diff=30&amp;oldid=prev</id>
		<title>WikiSysop: Created page with &quot;__NOTOC__ {| width=500  style=&quot;float:right; margin-left: 10px; margin-top: -56px;&quot; |Previous: Stateful Parsing |Next: More with Lists |} == Required course material for the lesson == Powerpoint: [https://teaching.healthtech.dtu.dk/material/22101/22101_09-Lists.ppt Lists and Sequences]&lt;br&gt; Video: [https://panopto.dtu.dk/Panopto/Pages/Viewer.aspx?id=871af158-9477-47c6-8e89-af27012d6e8d The basics of lists in python]&lt;br&gt; Video: [https://panopto.dtu.dk/Panopto/Pages/...&quot;</title>
		<link rel="alternate" type="text/html" href="https://teaching.healthtech.dtu.dk:443/22101/index.php?title=Lists/Sequences&amp;diff=30&amp;oldid=prev"/>
		<updated>2024-03-01T15:58:37Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;__NOTOC__ {| width=500  style=&amp;quot;float:right; margin-left: 10px; margin-top: -56px;&amp;quot; |Previous: &lt;a href=&quot;/22101/index.php/Stateful_Parsing&quot; title=&quot;Stateful Parsing&quot;&gt;Stateful Parsing&lt;/a&gt; |Next: &lt;a href=&quot;/22101/index.php/More_with_Lists&quot; title=&quot;More with Lists&quot;&gt;More with Lists&lt;/a&gt; |} == Required course material for the lesson == Powerpoint: [https://teaching.healthtech.dtu.dk/material/22101/22101_09-Lists.ppt Lists and Sequences]&amp;lt;br&amp;gt; Video: [https://panopto.dtu.dk/Panopto/Pages/Viewer.aspx?id=871af158-9477-47c6-8e89-af27012d6e8d The basics of lists in python]&amp;lt;br&amp;gt; Video: [https://panopto.dtu.dk/Panopto/Pages/...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;__NOTOC__&lt;br /&gt;
{| width=500  style=&amp;quot;float:right; margin-left: 10px; margin-top: -56px;&amp;quot;&lt;br /&gt;
|Previous: [[Stateful Parsing]]&lt;br /&gt;
|Next: [[More with Lists]]&lt;br /&gt;
|}&lt;br /&gt;
== Required course material for the lesson ==&lt;br /&gt;
Powerpoint: [https://teaching.healthtech.dtu.dk/material/22101/22101_09-Lists.ppt Lists and Sequences]&amp;lt;br&amp;gt;&lt;br /&gt;
Video: [https://panopto.dtu.dk/Panopto/Pages/Viewer.aspx?id=871af158-9477-47c6-8e89-af27012d6e8d The basics of lists in python]&amp;lt;br&amp;gt;&lt;br /&gt;
Video: [https://panopto.dtu.dk/Panopto/Pages/Viewer.aspx?id=e3b143a8-962c-40ee-bd10-af27012d502c Working with lists, modification]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Subjects covered ==&lt;br /&gt;
Lists and sequences.&amp;lt;br&amp;gt;&lt;br /&gt;
Lists methods for list manipulation;&amp;lt;br&amp;gt;&lt;br /&gt;
* changing an element&lt;br /&gt;
* adding/removing an element&lt;br /&gt;
* adding/removing more elements&lt;br /&gt;
* adding/removing elements at specific places&lt;br /&gt;
&lt;br /&gt;
== Exercises to be handed in ==&lt;br /&gt;
# Make a program that ask for words - one at a time - and saves them in a list (one word per element) until you write STOP. When STOP is entered, write the words in entered order in a file called &amp;#039;&amp;#039;words.txt&amp;#039;&amp;#039;.&lt;br /&gt;
# Searching for accession numbers. In the file &amp;#039;&amp;#039;ex5.acc&amp;#039;&amp;#039; there are 6461 unique GenBank accession numbers (taken from HU6800 DNA array chip). An inexperienced bioinformatician unfortunately fouled up the list, so many of the accession numbers appears more than once. Make a program that first reads the file into a list, then ask for an accession number and counts how many times it appears in the list and displays the result.&lt;br /&gt;
# Different search for accession numbers. This program is similar to the above. First read the file into a list, then continue to ask for accession numbers and check if they are in the list (yes/no, not a count). Keep searching for accession numbers until STOP is entered. Hint: this is 2 loops inside one another.&lt;br /&gt;
# &amp;lt;font color=&amp;quot;#AA00FF&amp;quot;&amp;gt;You need to clean up the &amp;#039;&amp;#039;ex5.acc&amp;#039;&amp;#039; file. The first step is to sort the accession numbers alphabetically. You must program a sorting algorithm. There are many different algorithms for sorting, but let&amp;#039;s pick a simple one - Bubble Sort.&amp;lt;br&amp;gt;It goes like this. Read the accessions into a list like the previous exercises. Go through the list looking at pairs of accessions (at position i &amp;amp; i+1). If a pair is in the wrong order, you switch them. Repeat going through the list until you have gone through the entire list without switching once. Now the list is sorted and you save the list in the &amp;#039;&amp;#039;sorted5.acc&amp;#039;&amp;#039; file.&amp;lt;br&amp;gt;Note: There is room for optimization in the described algorithm and it is in any case not the most efficient method. You are free to implement a different method.&amp;lt;/font&amp;gt;&lt;br /&gt;
# It is now time to find the unique accession numbers, so you only have one of each - no duplicates. Read the accessions from &amp;#039;&amp;#039;sorted5.acc&amp;#039;&amp;#039; into a list. Since the list is now sorted, the duplicates are &amp;quot;next&amp;quot; to each other, which makes them easy to find. Make a new list with the unique accessions from the old list, and save that list in the file &amp;#039;&amp;#039;clean5.acc&amp;#039;&amp;#039;. Check that you have 6461 accessions, one per line.&lt;br /&gt;
# In this exercise you have to do the same and achieve the same result in a different way as the previous exercise. Instead of making a new list with the unique accessions, just keep the old list and remove the duplicates using &amp;#039;&amp;#039;&amp;#039;del&amp;#039;&amp;#039;&amp;#039; or &amp;#039;&amp;#039;&amp;#039;pop&amp;#039;&amp;#039;&amp;#039;. If you run into trouble imagine your code executed on this list: [1, 2, 2, 3, 3, 3, 4, 4, 4, 4]&lt;br /&gt;
&lt;br /&gt;
== Exercises for extra practice ==&lt;br /&gt;
* Read two files with numbers into two lists. Files &amp;#039;&amp;#039;ex1_1.dat&amp;#039;&amp;#039;, &amp;#039;&amp;#039;ex1_2.dat&amp;#039;&amp;#039; &amp;amp; &amp;#039;&amp;#039;ex1_3.dat&amp;#039;&amp;#039; are good to use for this. Now add the numbers together, like the first number in the first file with the first number in the second file, and so forth, i.e. add the column in the file row-wise. You could also consider the numbers in a file to be a vector, and then you add two vectors together. Save the output (a list of numbers, one number per line) in a new file - you decide the name.&lt;br /&gt;
* Continuing previous exercise: Corrupt your input files a bit, change some numbers to not-numbers, like words or empty lines. Make your program work on these files too, assuming anything you can not read is ignored - you can &amp;quot;pretend&amp;quot; that there is a zero on the line you can not convert to a number.&lt;br /&gt;
* Continuing previous exercise: Make the program work even if the input files do not have the same length, just assume zero for the missing lines in the short file. BTW, you do not know which input is short.&lt;br /&gt;
* Read a file with numbers into two lists. The first number in the file goes to the first list, the second number to the second list, the third number to the first list, and so forth - alternating numbers to alternating lists. Compute the sum of the two lists and display. Files &amp;#039;&amp;#039;ex1_1.dat&amp;#039;&amp;#039;, &amp;#039;&amp;#039;ex1_2.dat&amp;#039;&amp;#039; &amp;amp; &amp;#039;&amp;#039;ex1_3.dat&amp;#039;&amp;#039; are good to use for this.&lt;br /&gt;
* Now compute the same sums - without the lists :-)&lt;br /&gt;
* Ask for files names and read the numbers in the file into a list. Continue to ask for file names and add the numbers to the list until you enter STOP. Now compute the sum of the numbers in the list and display the result. Files &amp;#039;&amp;#039;ex1_1.dat&amp;#039;&amp;#039;, &amp;#039;&amp;#039;ex1_2.dat&amp;#039;&amp;#039; &amp;amp; &amp;#039;&amp;#039;ex1_3.dat&amp;#039;&amp;#039; are good to use for this.&lt;/div&gt;</summary>
		<author><name>WikiSysop</name></author>
	</entry>
</feed>