简体   繁体   中英

Reading coordinates from Matrix file WITHOUT 2D arrays?

I'm currently working on a program (bioinformatics project) that involves reading multiple files, including a matrix, and outputting the results onto another file. What I'm having the most trouble with is how I would go about reading the matrix file like a coordinate system (for lack of a better term)? Is there a simple way to do this without using 2D arrays? For example, if I have the following amino acids in:

fileA: CTTNCLAPLA fileB: CTTNSITPVA

The program would then read the two files, compare each letter, and refer to the matrix to find the number corresponding to the two letters, which in turn determines the probability of a letter in fileA mutating to a letter in fileB.

Since the first letter in each file is C, the program would read the matrix and output in a separate file:

C T T N C L A P L A
| | | | . : : | : |
C T T N S I T P V A

The "." means that the number according to the matrix was 0 but not the same letter, "|" means that the letter is the same, and the ":" means that the number was greater than zero but not the same letter.

Here is part of the matrix (the rest wouldn't fit): NOTE: The matrix I must use is in a .csv file, and does not include spaces.

_, A, R, N, D, C
A, 2,-2, 0, 0,-2 
R,-2, 6, 0,-1,-2
N, 0, 0, 2, 2,-4
D, 0,-1, 2, 4,-5
C,-2,-4,-4,-5,12

I apologize if my explanation is confusing. Please let me know if you need any clarification. Any help is greatly appreciated. Thanks in advance!

为了避免使用2D数组,您可以将1D数组与线性索引一起使用,并实现便捷帮助器功能以将2D坐标转换为线性数组索引-像这里对称矩阵中的线性索引

I would just create a class / struct and then create a array of objects. This should eliminate your need for a 2D array.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM