[ You can use either "C#" or "Java" or "C++" code to answer ]
A01.cs is executed?
A01.cs, so that,
// A01.cs
using System;
using System.Collections;
public class A01
{
private static string ACGT = "ACGT";
private static int LE = ACGT.Length;
public static void Main(string[] args)
{
// init
ArrayList Data = new ArrayList();
Data.Add("CTAGCCAG");
Data.Add("ATGAAACA");
Data.Add("TTGATACG");
Data.Add("CGGACCTA");
Data.Add("CGGAGCCT");
Data.Add("TTACTAAT");
char A = ACGT[0];
ArrayList List = new ArrayList();
// compute one
int N = Data.Count;
for(int i=0; i<N; i++)
{
int k = 0;
string t = (string)Data[i];
int l = t.Length;
for(int j=0; j<l; j++)
if(t[j]==A)
++k;
List.Add(k);
}
// compute two
ArrayList PositionCountList = new ArrayList();
ArrayList SequenceList = new ArrayList();
int m = 0;
int Max = (int)List[m];
int Position = m;
N = List.Count;
for(m=1; m<N; m++)
if((int)List[m]>Max)
{
Max = (int)List[m];
Position = m;
}
PositionCountList.Add(Position);
PositionCountList.Add(Max);
SequenceList.Add(Data[Position]);
// output
N = SequenceList.Count;
for(int i=0; i<N; i++)
{
Console.Write("{0}", ((int)PositionCountList[i])+1);
Console.Write(". ");
Console.Write("{0}", (string)SequenceList[i]);
Console.Write(" - ");
Console.Write("{0}", (int)PositionCountList[i+1]);
Console.WriteLine();
}
}
}
A01.java is executed?
A01.java, so that,
// A01.java
import java.util.*;
public class A01 {
private final static String ACGT = "ACGT";
private final static int L = ACGT.length();
public static void main(String[] args) {
// init
String given[] = {"CTAGCCAG",
"ATGAAACA",
"TTGATACG",
"CGGACCTA",
"CGGAGCCT",
"TTACTAAT"};
List<String> data = Arrays.asList(given);
char a = ACGT.charAt(0);
ArrayList<Integer> list = new ArrayList<Integer>();
int n = data.size();
// compute one
for(int i=0; i<n; i++) {
int k = 0;
String t = data.get(i);
int l = t.length();
for(int j=0; j<l; j++)
if(t.charAt(j)==a)
++k;
list.add(new Integer(k));
}
// compute two
ArrayList<Integer> positionCountList = new ArrayList<Integer>();
ArrayList<String> sequenceList = new ArrayList<String>();
int i = 0;
int max = list.get(i);
int position = i;
n = list.size();
for(i=1; i<n; i++)
if(list.get(i)>max) {
max = list.get(i);
position = i;
}
positionCountList.add(position);
positionCountList.add(max);
sequenceList.add(data.get(position));
// output
n = sequenceList.size();
for(int j=0; j<n; j++) {
System.out.print(positionCountList.get(j)+1);
System.out.print(". ");
System.out.print(sequenceList.get(j));
System.out.print(" - ");
System.out.print(positionCountList.get(j+1));
System.out.println();
}
}
}
a_01.cpp is executed?
a_01.cpp, so that,
// a_01.cpp
#include <iostream>
#include <vector>
#include <string>
using namespace std;
const string ACGT = "ACGT";
int main(int argc, char* argv[]) {
const int L = ACGT.length();
// init
string given[] = {"CTAGCCAG",
"ATGAAACA",
"TTGATACG",
"CGGACCTA",
"CGGAGCCT",
"TTACTAAT"};
vector<string> data(given, given+6);
char a = ACGT.at(0);
vector<int> list;
// compute one
int n = data.size();
for(int i=0; i<n; i++) {
int k = 0;
string t = data.at(i);
int l = t.length();
for(int j=0; j<l; j++)
if(t.at(j)==a)
++k;
list.push_back(k);
}
// compute two
vector<int> position_count_list;
vector<string> sequence_list;
int i = 0;
int max = list[i];
int position = i;
n = list.size();
for(i=1; i<n; i++)
if(list[i]>max) {
max = list[i];
position = i;
}
position_count_list.push_back(position);
position_count_list.push_back(max);
sequence_list.push_back(data.at(position));
// output
n = sequence_list.size();
for(int i=0; i<n; i++) {
cout << position_count_list.at(i)+1;
cout << ". ";
cout << sequence_list.at(i);
cout << " - ";
cout << position_count_list.at(i+1);
cout << endl;
}
}