Skip to content

Commit

Permalink
v0.3.5
Browse files Browse the repository at this point in the history
fixed linux bug
added custom modlist param
  • Loading branch information
danny.geisz@gmail.com authored and danny.geisz@gmail.com committed Jul 30, 2020
1 parent bfcdc07 commit 21072c8
Show file tree
Hide file tree
Showing 2 changed files with 89 additions and 7 deletions.
24 changes: 18 additions & 6 deletions src/edu/umich/andykong/ptmshepherd/PTMShepherd.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,22 @@ public static synchronized void print(String s) {
}

public static void parseParamFile(String fn) throws Exception {
File f = new File(fn);
if(!f.exists())
die(String.format("Parameter file %s does not exist",fn));
BufferedReader in = new BufferedReader(new FileReader(f));
Path path = null;
//String fn2 = fn.replaceAll("\"", "");
//for (int i = 0; i < fn2.length(); i++) {
// System.out.println(fn.charAt(i) + "*");
//}
try {
path = Paths.get(fn.replaceAll("['\"]", ""));
} catch (Exception e) {
System.out.println(e);
die(String.format("Malformed parameter path string: [%s]", fn));
}
if (path == null || !Files.exists(path)) {
die(String.format("Parameter file does not exist: [%s]", fn));
}

BufferedReader in = new BufferedReader(new FileReader(path.toFile()));
String cline;
while((cline = in.readLine())!= null) {
int comments = cline.indexOf("//");
Expand All @@ -65,7 +77,7 @@ public static void parseParamFile(String fn) throws Exception {
datasets.put(dsName, new ArrayList<>());
datasets.get(dsName).add(new String[] {tsvTxt,mzPath});
} else {
params.put(key, value);
params.put(key, value.trim());
}
}
in.close();
Expand Down Expand Up @@ -119,7 +131,7 @@ public static void init(String [] args) throws Exception {
overrides.put(args[i].substring(2),args[i+1]);
i++;
} else
parseParamFile(args[i]);
parseParamFile(args[i].trim());
}
params.put("peakpicking_background", Double.toString(2.5*Double.parseDouble(params.get("peakpicking_width"))));
//replace overrides
Expand Down
72 changes: 71 additions & 1 deletion src/edu/umich/andykong/ptmshepherd/glyco/GlycoAnalysis.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
package edu.umich.andykong.ptmshepherd.glyco;

import edu.umich.andykong.ptmshepherd.PSMFile;
import edu.umich.andykong.ptmshepherd.PTMShepherd;
import edu.umich.andykong.ptmshepherd.core.MXMLReader;
import edu.umich.andykong.ptmshepherd.core.Spectrum;

import java.io.File;
import java.io.FileWriter;
import java.io.PrintWriter;
import java.io.RandomAccessFile;
import java.util.ArrayList;
import java.util.HashMap;

public class GlycoAnalysis {
Expand All @@ -14,13 +19,78 @@ public class GlycoAnalysis {
HashMap<String, MXMLReader> multiMr;
double ppmTol, condRatio, peakTol;
int condPeaks;
int specCol, pepCol, modpepCol, chargecol, deltaCol, rtCol, intCol;
int specCol, pepCol, modpepCol, chargecol, deltaCol, rtCol, intCol, pmassCol;

public GlycoAnalysis(String dsName) {
this.dsName = dsName;
glycoFile = new File(dsName+".rawglyco");
}

public void glycoPSMs(PSMFile pf, HashMap<String, File> mzMappings) throws Exception {
//open up output file
HashMap<String, ArrayList<Integer>> mappings = new HashMap<>();
PrintWriter out = new PrintWriter(new FileWriter(glycoFile, true));
//write header
out.printf("%s\t%s\t%s\t%s\t%s\n", "Spectrum", "Peptide", "Mod_Peptide", "Mass_Shift", "Pep_Mass");
//get necessary col indices
specCol = pf.getColumn("Spectrum");
pepCol = pf.getColumn("Peptide");
modpepCol = pf.getColumn("Modified Peptide");
//chargeCol = pf.getColumn("Charge");
deltaCol = pf.dMassCol;
rtCol = pf.getColumn("Retention");
intCol = pf.getColumn("Intensity");

//map PSMs to file
for (int i = 0; i < pf.data.size(); i++) {
String[] sp = pf.data.get(i).split("\t");
String bn = sp[specCol].substring(0, sp[specCol].indexOf(".")); //fraction
if (!mappings.containsKey(bn))
mappings.put(bn, new ArrayList<>());
}
for (int i = 0; i < pf.data.size(); i++) {
for (String fraction : mappings.keySet())
mappings.get(fraction).add(i);
}

for (String cf : mappings.keySet()) { //for file in relevant spectral files
long t1 = System.currentTimeMillis();
mr = new MXMLReader(mzMappings.get(cf), Integer.parseInt(PTMShepherd.getParam("threads")));
mr.readFully();
ArrayList<Integer> clines = mappings.get(cf); //lines corr to curr spec file
for (int i = 0; i < clines.size(); i++) {//for relevant line in curr spec file
try {
//out.println(processLine());
} catch (Exception e) {
e.printStackTrace();
System.out.println("Error in: " + pf.data.get(clines.get(i)));
}
}
}
}

public void processLine(String line) {
StringBuffer sb = new StringBuffer();
String [] sp = line.split("\\t");
String seq = sp[pepCol];
float dmass = Float.parseFloat(sp[deltaCol]);

String specName = sp[specCol];
//String [] smods = sp[modCol].split(",");

//sb.append(String.format("%s\t%s\t%s\t%.4f", specName,seq,sp[modCol],dmass));

//StringBuffer sb = new StringBuffer();
String [] s = line.split("\\t");
//Spectrum spec = mr.getSpectrum(reNormName(specName))
//findIonMasses();
//localizeRemainderFragments();
}

public void findIonMasses(float pepMass) {

}

public String reNormName(String s) {
String[] sp = s.split("\\.");
int sn = Integer.parseInt(sp[1]);
Expand Down

0 comments on commit 21072c8

Please sign in to comment.