на getIndexes (int number , int size , int characters)
Cant получить индекс строки в функции картографа
Я должен добавить преобразованное число в конце массива, как я должен применить отступы 0 предположим, его 231 ...
, который означает, что я поставить 6 нулей в начале, а затем 20.
//Input characters and Lenght of Motif
char [] inputChars = {'a','c','g','t'} ;
int lengthOfMotif = 8 ;
public void map(Object key, Text value, Context context) throws IOException, InterruptedException
{
/*
* To generate all the combinations of lengthOfMotif i used formula or probability to count of all possible strings that will be power of (inputChars length , elements in motif)
*
* Then i called my getIndexes method to get int[] of length lengthOfMotif representing an index from inputChars
*
* I generated a motif and made it key of Mapper and called minDistance returning minDistance,bestMatchingString,indexOfBestMatchingString and made it value for key motif
*
*
*/
for (int i = 0 ; i < Math.pow(inputChars.length, lengthOfMotif) ; i ++)
{
String motif = "" ; // initialize the empty motif string
for (int j : getIndexes (i , lengthOfMotif , inputChars.length)) //loop on array returned by getIndexes() with indexes to select from inputChar Array to build the string
{
motif = motif+inputChars[j] ;
}
context.write(new Text(motif), new Text (minDistance(motif,value.toString() ))) ;
}
}
// It takes a number , length of resultant indexes , number of unique characters
/*
* I convert the number to base of unique characters so the max index that can be generated will be less than the power
* then place the number at end of indexes array which will keep the starting indexes to be 0
*
* As our length is 8 and characters are 4 so
* if my number is 0
* i converted it to base 4 so it will remain 0
* i placed it at end of indexes array so my array will be like
* 0 0 0 0 0 0 0 0
* which in our case if considered as index of inputChars it will return
* a a a a a a a a
* The max number will be 8^4 = 65536 as we are starting from 0 our max number will be 65536
* in base 4 65536 is 3 3 3 3 3 3 3 3 which if we consider indexes will become
* t t t t t t t t
* So every number from 0 to 65536 will be covered and each combination will be passed as key of mapper
*
*/
int[] getIndexes (int number , int size , int characters)
{
//init new result array
int[] result = new int[size] ;
// I stuck here
}
return result ;
}
//return concatinated string in format minDistance,bestMatching,index
так добавить последнюю строку из вас MESG – user4594525
пояснит да основано на вас explination выше O является и 1 с разве, у вас есть только 4 буквы в качестве входных данных – khanos
у вас есть только 8 длина, так что 5 6 7 ИПА будет заполнен 231 – khanos