Skip to content

Commit

Permalink
create branched fragments for CUSTOM
Browse files Browse the repository at this point in the history
  • Loading branch information
juliomarcopineda committed Apr 17, 2018
1 parent ac7d469 commit 2118496
Show file tree
Hide file tree
Showing 2 changed files with 96 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,19 @@ private void findBranchedAndCyclicFragments(Map<String, Double> fragmentWeights)

// Append the linkers to the fragment (DFBP or S or SS) to form branched fragments
switch (type) {
case CUSTOM:
// Skip if the fragment contains CUSTOM
if (fragmentWith1.contains(peptideSequence.length())) {
continue;
}

// Only append CUSTOM if the connection is not in the beginning
if (fragmentWith1.get(0) != connection1) {
sb1.append("#%");
fragmentWeights.put(sb1.toString(), calculateBranchedFragmentWeight(sb1.toString()));
}

break;
case DFBP:
// Skip if the fragment contains DFBP
if (fragmentWith1.contains(peptideSequence.length())) {
Expand Down Expand Up @@ -174,8 +187,6 @@ private void findBranchedAndCyclicFragments(Map<String, Double> fragmentWeights)
break;
case LINEAR:
break;
default:
break;
}

// Start building branched fragments using the linear fragment with the second connection
Expand All @@ -192,6 +203,15 @@ private void findBranchedAndCyclicFragments(Map<String, Double> fragmentWeights)
sb2.append(getPeptideStringRepresentation(fragmentWith1, type));
if (isValidBranchedFragment(afterConnection1, beforeConnection2)) {
switch (type) {
case CUSTOM:
// Skip if the fragment contains CUSTOM
if (fragmentWith2.contains(peptideSequence.length())) {
continue;
}

sb2.append("#%#" + getPeptideStringRepresentation(fragmentWith2, type));
fragmentWeights.put(sb2.toString(), calculateBranchedFragmentWeight(sb2.toString()));
break;
case DFBP:
// Skip if the fragment contains DFBP
if (fragmentWith2.contains(peptideSequence.length())) {
Expand All @@ -214,7 +234,7 @@ private void findBranchedAndCyclicFragments(Map<String, Double> fragmentWeights)
sb2.append("#" + getPeptideStringRepresentation(fragmentWith2, type));
fragmentWeights.put(sb2.toString(), calculateBranchedFragmentWeight(sb2.toString()));
break;
default:
case LINEAR:
break;
}
}
Expand All @@ -230,6 +250,19 @@ private void findBranchedAndCyclicFragments(Map<String, Double> fragmentWeights)

// Append the linkers (DFBP or S or SS) to form possible branched fragments
switch (type) {
case CUSTOM:
// Skip if linear fragment contains CUSTOM
if (fragmentWith2.contains(peptideSequence.length())) {
continue;
}

// Only append CUSTOM if connection is not in the end of the fragment
if (fragmentWith2.get(fragmentWith2.size() - 1) != connection2) {
sb1.append("#%");
fragmentWeights.put(sb1.toString(), calculateBranchedFragmentWeight(sb1.toString()));
}

break;
case DFBP:
// Skip if linear fragment contains DFBP
if (fragmentWith2.contains(peptideSequence.length())) {
Expand Down Expand Up @@ -258,7 +291,9 @@ private void findBranchedAndCyclicFragments(Map<String, Double> fragmentWeights)
}

break;
default:
case AMIDE:
break;
case LINEAR:
break;
}

Expand All @@ -276,6 +311,16 @@ private void findBranchedAndCyclicFragments(Map<String, Double> fragmentWeights)
sb2.append(getPeptideStringRepresentation(fragmentWith1, type));
if (isValidBranchedFragment(afterConnection1, beforeConnection2)) {
switch (type) {
case CUSTOM:
// Skip if fragment contains CUSTOM
if (fragmentWith1.contains(peptideSequence.length())) {
continue;
}

sb2.append("#%#" + getPeptideStringRepresentation(fragmentWith1, type));

fragmentWeights.put(sb2.toString(), calculateBranchedFragmentWeight(sb2.toString()));
break;
case DFBP:
// Skip if fragment contains DFBP
if (fragmentWith1.contains(peptideSequence.length())) {
Expand All @@ -301,8 +346,6 @@ private void findBranchedAndCyclicFragments(Map<String, Double> fragmentWeights)
break;
case LINEAR:
break;
default:
break;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package com.github.juliomarcopineda.tests;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

import com.github.juliomarcopineda.FragmentAnalyzer;
import com.github.juliomarcopineda.PeptideSerumStability;
import com.github.juliomarcopineda.peptide.Peptide;
import com.github.juliomarcopineda.peptide.PeptideType;

/**
* This class prints out all the branched fragments for a peptide to check if the branched fragment builder
* is working.
*
* @author Julio Pineda
*
*/
public class BranchedFragmentTest {

public static void main(String[] args) {
Peptide peptide = new Peptide();

String peptideSequence = "CGYEQDPWGVRYWYGCKKKKB";
PeptideType type = PeptideType.CUSTOM;
double customWeight = 383.32;
List<Integer> connections = Arrays.asList(4, 19);
Map<Integer, List<Integer>> graph = PeptideSerumStability.createGraphStructure(peptideSequence, connections, type);

peptide.setSequence(peptideSequence);
peptide.setType(type);
peptide.setConnections(connections);
peptide.setCustomWeight(customWeight);
peptide.setGraph(graph);

FragmentAnalyzer analyzer = new FragmentAnalyzer(peptide);
analyzer.findAllFragments()
.measureAllFragmentWeights();

analyzer.getFragmentWeights()
.keySet()
.stream()
.filter(s -> s.contains("#"))
.forEach(System.out::println);
}

}

0 comments on commit 2118496

Please sign in to comment.