Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

ChIP-seq is used to identify genomic segments bound by transcription factors. In

ID: 3846175 • Letter: C

Question

ChIP-seq is used to identify genomic segments bound by transcription factors. In a ChIP-seq experiment, you obtain the chromosome regions that the transcription factor FoxA is binding. Write a Matlab function locationtogenes(chr,start,finish,genefile) that takes a chromosome name, the start and finish of the chromosome region in base pairs, and a gene-location file; and determines which genes are located in that region. The gene-location file is a tab-delimited text file where each line contains chromosome-start-finish-genename. Find the genes whose position overlaps with the input range (the gene doesn't have to be completely enclosed in the input range to be considered overlapping; at least one nucleotide overlap is sufficient). Return these genes as a cell array. If no genes are found in an input range, return an empty cell array.

Example:

>> disp(locationtogenes('chr1',59000000,59247000,'genelocs_sample.txt'))
    'JUN'
>> disp(locationtogenes('chr1',50000000,100000000,'genelocs_sample.txt'))
    'RP4-784A16.2'    'MRPL37'    'JUN'    'LRRC8C'

You may follow the pseudocode below or design & implement your own approach.

Explanation / Answer

function [ out ] = locationtogenes( chr,start,finish,genefile )

%UNTITLED Summary of this function goes here

%   Detailed explanation goes here

f=fopen(genefile,'r'); %open file

out=[];

while ~feof(f)

    line = fgetl(f);

    locs=find(line==sprintf(' '));

      if numel(locs)<3; continue; end

      if strfind(line,chr)>0

          chr1= line(locs(1)+1 : locs(2)-1);

          if strfind(line,start)>0

          start1= line(locs(2)+1 : locs(3)-1);

          if strfind(line,finish)>0

          finish1= line(locs(3)+1 : locs(4)-1);

          if strfind(line,genename)>0

          genename= line(locs(4)+1 : locs(5)-1);

          break;

          if start1==start && finish1==finish

              out=genename

              break;

          end

          end

          end

          end

      end

end

end