1 /* 2 Copyright 2007, 2008 Daniel Zerbino (zerbino@ebi.ac.uk) 3 4 This file is part of Velvet. 5 6 Velvet is free software; you can redistribute it and/or modify 7 it under the terms of the GNU General Public License as published by 8 the Free Software Foundation; either version 2 of the License, or 9 (at your option) any later version. 10 11 Velvet is distributed in the hope that it will be useful, 12 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 GNU General Public License for more details. 15 16 You should have received a copy of the GNU General Public License 17 along with Velvet; if not, write to the Free Software 18 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 19 20 */ 21 #ifndef _PASSAGEMARKER_H_ 22 #define _PASSAGEMARKER_H_ 23 24 struct passageList_st { 25 PassageMarkerI marker; 26 PassageMarkerList *next; 27 } ATTRIBUTE_PACKED; 28 29 /////////////////////////////////////////////////////////////////// 30 // PassageMarker lists 31 /////////////////////////////////////////////////////////////////// 32 // You can always malloc a PassaegMarkerList but these routines manage the 33 // memory for you, thus avoiding fragmentation 34 PassageMarkerList *newPassageMarkerList(PassageMarkerI marker, 35 PassageMarkerList * next); 36 37 void deallocatePassageMarkerList(PassageMarkerList * list); 38 39 /////////////////////////////////////////////////////////////////// 40 // Creators/Destructors 41 /////////////////////////////////////////////////////////////////// 42 PassageMarkerI addPassageMarker(IDnum sequenceID, Coordinate start, 43 Node * node); 44 45 PassageMarkerI addUncertainPassageMarker(IDnum sequenceID, Node * node); 46 47 PassageMarkerI newPassageMarker(IDnum seqID, Coordinate start, 48 Coordinate finish, Coordinate startOffset, 49 Coordinate finishOffset); 50 51 // Deallocates but also removes all pointers towards that structure 52 void destroyPassageMarker(PassageMarkerI marker); 53 void destroyAllPassageMarkers(); 54 55 /////////////////////////////////////////////////////////////////// 56 // Node 57 /////////////////////////////////////////////////////////////////// 58 59 // Current node 60 Node *getNode(PassageMarkerI marker); 61 62 // Yank out of current node 63 void extractPassageMarker(PassageMarkerI marker); 64 65 // Insert into a node 66 void transposePassageMarker(PassageMarkerI marker, Node * destination); 67 68 /////////////////////////////////////////////////////////////////// 69 // General Info 70 /////////////////////////////////////////////////////////////////// 71 // Export into file 72 void exportMarker(FILE * outfile, PassageMarkerI marker, 73 TightString * sequences, int wordLength); 74 75 // General info for debugging 76 char *readPassageMarker(PassageMarkerI marker); 77 78 // Sequence ID associated to the passage marker 79 IDnum getPassageMarkerSequenceID(PassageMarkerI marker); 80 IDnum getAbsolutePassMarkerSeqID(PassageMarkerI marker); 81 int passageMarkerDirection(PassageMarkerI marker); 82 83 // Coordinates 84 Coordinate getPassageMarkerStart(PassageMarkerI marker); 85 void setPassageMarkerStart(PassageMarkerI marker, Coordinate start); 86 Coordinate getPassageMarkerFinish(PassageMarkerI marker); 87 void setPassageMarkerFinish(PassageMarkerI marker, Coordinate finish); 88 Coordinate getPassageMarkerLength(PassageMarkerI marker); 89 90 // Offsets 91 Coordinate getStartOffset(PassageMarkerI marker); 92 void setStartOffset(PassageMarkerI marker, Coordinate offset); 93 void incrementStartOffset(PassageMarkerI marker, Coordinate offset); 94 Coordinate getFinishOffset(PassageMarkerI marker); 95 void setFinishOffset(PassageMarkerI marker, Coordinate offset); 96 void incrementFinishOffset(PassageMarkerI marker, Coordinate offset); 97 98 // Status 99 void setPassageMarkerStatus(PassageMarkerI marker, boolean status); 100 boolean getPassageMarkerStatus(PassageMarkerI marker); 101 102 /////////////////////////////////////////////////////////////////// 103 // Marker Sequences 104 /////////////////////////////////////////////////////////////////// 105 106 // Corresponding marker of reverse complement sequence 107 PassageMarkerI getTwinMarker(PassageMarkerI marker); 108 109 // Within a node 110 PassageMarkerI getNextInNode(PassageMarkerI marker); 111 void setNextInNode(PassageMarkerI marker, PassageMarkerI next); 112 void setTopOfTheNode(PassageMarkerI marker); 113 114 // Within a sequence 115 PassageMarkerI getNextInSequence(PassageMarkerI marker); 116 void setNextInSequence(PassageMarkerI previous, PassageMarkerI next); 117 PassageMarkerI getPreviousInSequence(PassageMarkerI marker); 118 void setPreviousInSequence(PassageMarkerI previous, PassageMarkerI next); 119 void connectPassageMarkers(PassageMarkerI previous, PassageMarkerI next, 120 Graph * graph); 121 122 // End of read chains 123 boolean isTerminal(PassageMarkerI marker); 124 boolean isInitial(PassageMarkerI marker); 125 126 // Checks whether the node of the next marker is the one given in parameter 127 boolean isDestinationToMarker(PassageMarkerI marker, Node * node); 128 129 // Bypasses the middle marker 130 void disconnectNextPassageMarker(PassageMarkerI marker, Graph * graph); 131 void deleteNextPassageMarker(PassageMarkerI marker, Graph * graph); 132 133 // Merge two markers (cf concatenateGraph()) 134 void concatenatePassageMarkers(PassageMarkerI marker, 135 PassageMarkerI nextMarker); 136 137 #endif 138