Skip to content

Commit

Permalink
Change according to ProteomicsLibrary's changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
fcyu committed Apr 10, 2018
1 parent 2e63cef commit 142fbae
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 35 deletions.
15 changes: 0 additions & 15 deletions src/main/java/proteomics/ECL2.java
Original file line number Diff line number Diff line change
Expand Up @@ -143,21 +143,6 @@ private ECL2(String parameter_path, String spectra_path, String dbName) throws E

PreSpectra preSpectra = new PreSpectra(spectra_parser, ms1Tolerance, leftInverseMs1Tolerance, rightInverseMs1Tolerance, ms1ToleranceUnit, build_index_obj, parameter_map, ext, sqlPath);

if (dev && parameter_map.get("C13_correction").contentEquals("1")) {
BufferedWriter writer = new BufferedWriter(new FileWriter("spectrum.dev.csv"));
writer.write("scanNum,charge,finalIsotopeCorrectionNum,isotopeCorrectionNum,pearsonCorrelationCoefficient,expMz1,expMz2,expMz3,expInt1,expInt2,expInt3,theoMz1,theoMz2,theoMz3,theoInt1,theoInt2,theoInt3\n");
Map<Integer, TreeMap<Integer, TreeSet<IsotopeDistribution.DevEntry>>> scanDevEntryMap = preSpectra.getScanDevEntryMap();
for (int scanNum : scanDevEntryMap.keySet()) {
TreeMap<Integer, TreeSet<IsotopeDistribution.DevEntry>> chargeDevEntryMap = scanDevEntryMap.get(scanNum);
for (int charge : chargeDevEntryMap.keySet()) {
for (IsotopeDistribution.DevEntry devEntry : chargeDevEntryMap.get(charge)) {
writer.write(String.format(Locale.US, "%d,%d,%d,%d,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f\n", scanNum, charge, devEntry.isotopeCorrectionNum, devEntry.isotopeCorrectionNum, devEntry.pearsonCorrelationCoefficient, devEntry.expMatrix[0][0], devEntry.expMatrix[1][0], devEntry.expMatrix[2][0], devEntry.expMatrix[0][1], devEntry.expMatrix[1][1], devEntry.expMatrix[2][1], devEntry.theoMatrix[0][0], devEntry.theoMatrix[1][0], devEntry.theoMatrix[2][0], devEntry.theoMatrix[0][1], devEntry.theoMatrix[1][1], devEntry.theoMatrix[2][1]));
}
}
}
writer.close();
}

logger.info("Start searching...");

int thread_num = Integer.valueOf(parameter_map.get("thread_num"));
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/proteomics/Index/BuildIndex.java
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public BuildIndex(Map<String, String> parameter_map) throws Exception {
}

// define a new MassTool object
mass_tool_obj = new MassTool(missed_cleavage, fix_mod_map, "KR", "P", true, mz_bin_size * 0.5, one_minus_bin_offset, "N14", "[]");
mass_tool_obj = new MassTool(missed_cleavage, fix_mod_map, "KR", "P", true, mz_bin_size * 0.5, one_minus_bin_offset, "N14");

// generate seq_pro_map
Map<String, boolean[]> seq_term_map = new HashMap<>();
Expand Down Expand Up @@ -513,10 +513,10 @@ private List<Map<Integer, Double>> generateLocalIdxModMassMap(int[] idxArray, Ma
private Set<String> checkKCTermMod(Set<String> varSeqSet) { // eliminate those sequence that the middle amino acids having the same mod mass and the n-term and the first amino acid or the c-term and the last amino acid have the same mod mass. todo: check
String[] varSeqArray = varSeqSet.toArray(new String[0]);
Arrays.sort(varSeqArray); // Make sure that nK[].... is before n[]K..., so that n[]K... will be kept.
int seqLength = MassTool.seqToAAList(varSeqArray[0], "[]").length;
int seqLength = MassTool.seqToAAList(varSeqArray[0]).length;
AA[][] aaArrays = new AA[varSeqArray.length][seqLength];
for (int i = 0; i < varSeqArray.length; ++i) {
aaArrays[i] = MassTool.seqToAAList(varSeqArray[i], "[]");
aaArrays[i] = MassTool.seqToAAList(varSeqArray[i]);
}

if (aaArrays.length > 1) {
Expand Down Expand Up @@ -549,7 +549,7 @@ private Set<String> checkKCTermMod(Set<String> varSeqSet) { // eliminate those s
}

private Set<Short> getLinkSiteSet(String seq, boolean n_term, boolean c_term, short linker_type) {
AA[] aa_list = MassTool.seqToAAList(seq, "[]");
AA[] aa_list = MassTool.seqToAAList(seq);
Set<Short> output = new HashSet<>(5, 1);
for (int i = 1; i < aa_list.length - 2; ++i) {
if (linker_type == 1 && aa_list[i].aa == 'K' && (Math.abs(aa_list[i].ptmDeltaMass) < varModMassResolution)) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/proteomics/Search/SearchWrap.java
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ private int getC13Num(double exp_mass, double theo_mass) {

private String addFixMod(String seq, int linkSite) {
Map<Character, Double> fix_mod_map = build_index_obj.getFixModMap();
AA[] aaList = MassTool.seqToAAList(seq, "[]");
AA[] aaList = MassTool.seqToAAList(seq);
StringBuilder sb = new StringBuilder(seq.length() * 3);
for (int i = 0; i < aaList.length; ++i) {
AA aa = aaList[i];
Expand Down
17 changes: 2 additions & 15 deletions src/main/java/proteomics/Spectrum/PreSpectra.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,9 @@ public class PreSpectra {
private static final Logger logger = LoggerFactory.getLogger(PreSpectra.class);
private static final Pattern pattern = Pattern.compile("^[0-9]+$");

private Map<Integer, TreeMap<Integer, TreeSet<IsotopeDistribution.DevEntry>>> scanDevEntryMap = new HashMap<>();
private int usefulSpectraNum = 0;

public PreSpectra(JMzReader spectra_parser, double ms1Tolerance, double leftInverseMs1Tolerance, double rightInverseMs1Tolerance, int ms1ToleranceUnit, BuildIndex build_index_obj, Map<String, String> parameter_map, String ext, String sqlPath) throws MzXMLParsingException, IOException, SQLException, JMzReaderException {
public PreSpectra(JMzReader spectra_parser, double ms1Tolerance, double leftInverseMs1Tolerance, double rightInverseMs1Tolerance, int ms1ToleranceUnit, BuildIndex build_index_obj, Map<String, String> parameter_map, String ext, String sqlPath) throws Exception {
Set<Integer> debug_scan_num_set = new HashSet<>();
// In DEBUG mode, filter out unlisted scan num
if (ECL2.debug) {
Expand Down Expand Up @@ -101,10 +100,6 @@ public PreSpectra(JMzReader spectra_parser, double ms1Tolerance, double leftInve
int rt = -1;
int isotopeCorrectionNum = 0;
double pearsonCorrelationCoefficient = -1;
TreeMap<Integer, TreeSet<IsotopeDistribution.DevEntry>> chargeDevEntryMap = null;
if (ECL2.dev) {
chargeDevEntryMap = new TreeMap<>();
}
if (ext.toLowerCase().contentEquals("mgf")) {
mgfTitle = ((Ms2Query) spectrum).getTitle();
scan_num = getScanNum(mgfTitle);
Expand All @@ -115,7 +110,7 @@ public PreSpectra(JMzReader spectra_parser, double ms1Tolerance, double leftInve
if (parameter_map.get("C13_correction").contentEquals("1")) {
TreeMap<Double, Double> parentPeakList = new TreeMap<>(spectra_parser.getSpectrumById(parentId).getPeakList());
// We do not try to correct the precursor charge if there is one.
IsotopeDistribution.Entry entry = isotopeDistribution.getIsotopeCorrectionNum(precursor_mz, ms1Tolerance, ms1ToleranceUnit, precursor_charge, parentPeakList, chargeDevEntryMap);
IsotopeDistribution.Entry entry = isotopeDistribution.getIsotopeCorrectionNum(precursor_mz, ms1Tolerance, ms1ToleranceUnit, precursor_charge, parentPeakList);
if (entry.pearsonCorrelationCoefficient >= 0.7) { // If the Pearson correlation coefficient is smaller than 0.7, there is not enough evidence to change the original precursor mz.
isotopeCorrectionNum = entry.isotopeCorrectionNum;
pearsonCorrelationCoefficient = entry.pearsonCorrelationCoefficient;
Expand All @@ -136,10 +131,6 @@ public PreSpectra(JMzReader spectra_parser, double ms1Tolerance, double leftInve
sqlPrepareStatement.setDouble(10, pearsonCorrelationCoefficient);
sqlPrepareStatement.executeUpdate();
++usefulSpectraNum;

if (ECL2.dev) {
scanDevEntryMap.put(scan_num, chargeDevEntryMap);
}
} catch (RuntimeException ex) {
logger.error(ex.toString());
}
Expand All @@ -151,10 +142,6 @@ public PreSpectra(JMzReader spectra_parser, double ms1Tolerance, double leftInve
logger.info("Useful MS/MS spectra number: {}.", usefulSpectraNum);
}

public Map<Integer, TreeMap<Integer, TreeSet<IsotopeDistribution.DevEntry>>> getScanDevEntryMap() {
return scanDevEntryMap;
}

public int getUsefulSpectraNum() {
return usefulSpectraNum;
}
Expand Down

0 comments on commit 142fbae

Please sign in to comment.